--- /dev/null
+#################################################################################
+# Kiriwrite Database Module - MySQL 5.x Database Module (MySQL5.pm) #
+# Database module for mainipulating data in a MySQL 5.x database. #
+# #
+# Copyright (C) 2007 Steve Brokenshire <sbrokenshire@xestia.co.uk> #
+# #
+# This module is licensed under the same license as Kiriwrite which is the GPL. #
+# #
+# This program is free software; you can redistribute it and/or modify it under #
+# the terms of the GNU General Public License as published by the Free #
+# Software Foundation; as version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.#
+# #
+# You should have received a copy of the GNU General Public License along with #
+# this program; if not, write to the Free Software Foundation, Inc., 51 #
+# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
+#################################################################################
+
+# Define the package (perl module) name.
+
+package Kiriwrite::Database::MySQL;
+
+# Enable strict and use warnings.
+
+use strict;
+use warnings;
+use Encode;
+
+# Load the following Perl modules.
+
+use DBI;
+
+# Set the following values.
+
+our $VERSION = "0.1.0";
+my ($options, %options);
+my $database_handle;
+my $string_handle;
+my $error;
+my $errorext;
+my $database_filename;
+my $second_database_filename;
+
+#################################################################################
+# Generic Subroutines. #
+#################################################################################
+
+sub new{
+#################################################################################
+# new: Create an instance of Kiriwrite::Database::MySQL #
+# #
+# Usage: #
+# #
+# $dbmodule = Kiriwrite::Database::SQLite->new(); #
+#################################################################################
+
+ # Get the perl module name.
+
+ my $class = shift;
+ my $self = {};
+
+ return bless($self, $class);
+
+}
+
+sub loadsettings{
+#################################################################################
+# loadsettings: Loads settings into the SQLite database module #
+# #
+# Usage: #
+# #
+# $dbmodule->loadsettings(Directory, options); #
+# #
+# options Specifies the following options (in any order). #
+# #
+# Directory Specifies the directory to use for getting databases. #
+# DateTime Specifies the date and time format to use. #
+# Server Specifies the server to use. #
+# Database Specifies the database to use. #
+# Username Specifies the username to use. #
+# Password Specifies the password to use. #
+# Port Specifies the server port to use. #
+# Protocol Specifies the protocol to use. #
+# TablePrefix Specifies the table prefix to use. #
+#################################################################################
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ # Add the directory setting to the list of options (as it's the only
+ # one needed for this database module).
+
+ %options = (
+ "Directory" => $passedoptions->{"Directory"},
+ "DateTime" => $passedoptions->{"DateTime"},
+ "Server" => $passedoptions->{"Server"},
+ "Database" => $passedoptions->{"Database"},
+ "Username" => $passedoptions->{"Username"},
+ "Password" => $passedoptions->{"Password"},
+ "Port" => $passedoptions->{"Port"},
+ "Protocol" => $passedoptions->{"Protocol"},
+ "TablePrefix" => $passedoptions->{"TablePrefix"}
+ );
+
+}
+
+sub convert{
+#################################################################################
+# convert: Converts data into SQL formatted data. #
+# #
+# Usage: #
+# #
+# $dbmodule->convert(data); #
+# #
+# data Specifies the data to convert. #
+#################################################################################
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my $data = shift;
+
+ if (!$data){
+ $data = "";
+ }
+
+ $data =~ s/'/''/g;
+ $data =~ s/\b//g;
+
+ return $data;
+
+}
+
+sub dateconvert{
+#################################################################################
+# dateconvert: Converts a SQL date into a proper date. #
+# #
+# Usage: #
+# #
+# $dbmodule->dateconvert(date); #
+# #
+# date Specifies the date to convert. #
+#################################################################################
+
+ # Get the date passed to the subroutine.
+
+ my $class = shift;
+ my $data = shift;
+
+ # Convert the date given into the proper date.
+
+ # Create the following varialbes to be used later.
+
+ my $date;
+ my $time;
+ my $day;
+ my $day_full;
+ my $month;
+ my $month_check;
+ my $month_full;
+ my $year;
+ my $year_short;
+ my $hour;
+ my $hour_full;
+ my $minute;
+ my $minute_full;
+ my $second;
+ my $second_full;
+ my $seek = 0;
+ my $timelength;
+ my $datelength;
+ my $daylength;
+ my $secondlength;
+ my $startchar = 0;
+ my $char;
+ my $length;
+ my $count = 0;
+
+ # Split the date and time.
+
+ $length = length($data);
+
+ if ($length > 0){
+
+ do {
+
+ # Get the character and check if it is a space.
+
+ $char = substr($data, $seek, 1);
+
+ if ($char eq ' '){
+
+ # The character is a space, so get the date and time.
+
+ $date = substr($data, 0, $seek);
+ $timelength = $length - $seek - 1;
+ $time = substr($data, $seek + 1, $timelength);
+
+ }
+
+ $seek++;
+
+ } until ($seek eq $length);
+
+ # Get the year, month and date.
+
+ $length = length($date);
+ $seek = 0;
+
+ do {
+
+ # Get the character and check if it is a dash.
+
+ $char = substr($date, $seek, 1);
+
+ if ($char eq '-'){
+
+ # The character is a dash, so get the year, month or day.
+
+ $datelength = $seek - $startchar;
+
+ if ($count eq 0){
+
+ # Get the year from the date.
+
+ $year = substr($date, 0, $datelength) + 1900;
+ $startchar = $seek;
+ $count = 1;
+
+ # Get the last two characters to get the short year
+ # version.
+
+ $year_short = substr($year, 2, 2);
+
+ } elsif ($count eq 1){
+
+ # Get the month and day from the date.
+
+ $month = substr($date, $startchar + 1, $datelength - 1) + 1;
+
+ # Check if the month is less then 10, if it is
+ # add a zero to the value.
+
+ if ($month < 10){
+
+ $month_full = '0' . $month;
+
+ } else {
+
+ $month_full = $month;
+
+ }
+
+ $startchar = $seek;
+ $count = 2;
+
+ $daylength = $length - $seek + 1;
+ $day = substr($date, $startchar + 1, $daylength);
+
+ $day =~ s/^0//;
+
+ # Check if the day is less than 10, if it is
+ # add a zero to the value.
+
+ if ($day < 10){
+
+ $day_full = '0' . $day;
+
+ } else {
+
+ $day_full = $day;
+
+ }
+
+ }
+
+ }
+
+ $seek++;
+
+ } until ($seek eq $length);
+
+ # Get the length of the time value and reset certain
+ # values to 0.
+
+ $length = length($time);
+ $seek = 0;
+ $count = 0;
+ $startchar = 0;
+
+ do {
+
+ # Get the character and check if it is a colon.
+
+ $char = substr($time, $seek, 1);
+
+ if ($char eq ':'){
+
+ # The character is a colon, so get the hour, minute and day.
+
+ $timelength = $seek - $startchar;
+
+ if ($count eq 0){
+
+ # Get the hour from the time.
+
+ $hour = substr($time, 0, $timelength);
+ $hour =~ s/^0//;
+ $count = 1;
+ $startchar = $seek;
+
+ # If the hour is less than ten then add a
+ # zero.
+
+ if ($hour < 10){
+
+ $hour_full = '0' . $hour;
+
+ } else {
+
+ $hour_full = $hour;
+
+ }
+
+ } elsif ($count eq 1){
+
+ # Get the minute and second from the time.
+
+ $minute = substr($time, $startchar + 1, $timelength - 1);
+ $minute =~ s/^0//;
+ $count = 2;
+
+ # If the minute is less than ten then add a
+ # zero.
+
+ if ($minute < 10){
+
+ $minute_full = '0' . $minute;
+
+ } else {
+
+ $minute_full = $minute;
+
+ }
+
+ $startchar = $seek;
+
+ $secondlength = $length - $seek + 1;
+ $second = substr($time, $startchar + 1, $secondlength);
+ $second =~ s/^0//;
+
+ # If the second is less than ten then add a
+ # zero.
+
+ if ($second < 10){
+
+ $second_full = '0' . $second;
+
+ } else {
+
+ $second_full = $second;
+
+ }
+
+ }
+
+ }
+
+ $seek++;
+
+ } until ($seek eq $length);
+
+ # Get the setting for displaying the date and time.
+
+ $data = $options{"DateTime"};
+
+ # Process the setting for displaying the date and time
+ # using regular expressions
+
+ $data =~ s/DD/$day_full/g;
+ $data =~ s/D/$day/g;
+ $data =~ s/MM/$month_full/g;
+ $data =~ s/M/$month/g;
+ $data =~ s/YY/$year/g;
+ $data =~ s/Y/$year_short/g;
+
+ $data =~ s/hh/$hour_full/g;
+ $data =~ s/h/$hour/g;
+ $data =~ s/mm/$minute_full/g;
+ $data =~ s/m/$minute/g;
+ $data =~ s/ss/$second_full/g;
+ $data =~ s/s/$second/g;
+
+ }
+
+ return $data;
+
+}
+
+sub geterror{
+#################################################################################
+# geterror: Gets the error message (or extended error message). #
+# #
+# Usage: #
+# #
+# $dbmodule->geterror(extended); #
+# #
+# Extended Specifies if the extended error should be retrieved. #
+#################################################################################
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my $extended = shift;
+
+ if (!$extended){
+ $extended = 0;
+ }
+
+ if (!$errorext){
+ $errorext = "";
+ }
+
+ if (!$error){
+ $error = "";
+ }
+
+ # Check to see if extended information should be returned.
+
+ if ($extended eq 1){
+
+ # Extended information should be returned.
+
+ return $errorext;
+
+ } else {
+
+ # Basic information should be returned.
+
+ return $error;
+
+ }
+
+}
+
+sub dbpermissions{
+#################################################################################
+# dbpermissions: Check if the permissions for the database are valid. #
+# #
+# Usage: #
+# #
+# $database->dbpermissions(dbname, read, write); #
+# #
+# dbname Specifies the database name to check. #
+# read Check to see if the database can be read. #
+# write Check to see if the database can be written. #
+#################################################################################
+
+ # This subroutine is not needed for this database module.
+
+ return 0;
+
+}
+
+sub dbexists{
+#################################################################################
+# dbexists: Check if the database exists. #
+# #
+# Usage: #
+# #
+# $dbmodule->dbexists(dbname); #
+# #
+# dbname Specifies the database name to check. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the value that was passed to the subroutine.
+
+ my $class = shift;
+ my ($filename) = @_;
+
+ my @table_data;
+ my $table_exists = 0;
+
+ # Check if the table exists.
+
+ $string_handle = $database_handle->prepare('SHOW TABLES LIKE \'' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($filename) . '_database_info\'') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@table_data = $string_handle->fetchrow_array()){
+
+ $table_exists = 1;
+
+ }
+
+ # Check if the table really does exist.
+
+ if ($table_exists eq 1){
+
+ # The table exists so return a value of 0.
+
+ return 0;
+
+ } else {
+
+ # The table does not exist so return a value of 1.
+
+ return 1;
+
+ }
+
+}
+
+
+#################################################################################
+# General subroutines. #
+#################################################################################
+
+sub connect{
+#################################################################################
+# connect: Connect to the server. #
+# #
+# Usage: #
+# #
+# $dbmodule->connect(); #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Connect to the server.
+
+ $database_handle = DBI->connect("DBI:mysql:database=" . $options{"Database"} . ";host=" . $options{"Server"} . ";protocol=" . $options{"Protocol"} . "port=" . $options{"Port"}, $options{"Username"}, $options{"Password"}, { "mysql_enable_utf8" => 1 }) or ( $error = "DatabaseConnectionError", $errorext = DBI->errstr, return );
+ $database_handle->do('SET CHARACTER SET utf8');
+ $database_handle->do('SET NAMES utf8');
+
+}
+
+sub disconnect{
+#################################################################################
+# connect: Disconnect from the server. #
+# #
+# Usage: #
+# #
+# $dbmodule->disconnect(); #
+#################################################################################
+
+ # Disconnect from the server.
+
+ if ($string_handle){
+
+ $string_handle->finish();
+
+ }
+
+ if ($database_handle){
+
+ $database_handle->disconnect();
+
+ }
+
+}
+
+#################################################################################
+# Database Subroutines. #
+#################################################################################
+
+sub getdblist{
+#################################################################################
+# getdblist: Gets the list of available databases. #
+# #
+# Usage: #
+# #
+# $dbmodule->getdblist(); #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the list of databases.
+
+ $string_handle = $database_handle->prepare("SHOW TABLES") or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ my @final_table_list;
+ my @database_table_list;
+ my @table_name;
+ my $table;
+
+ while (@table_name = $string_handle->fetchrow_array()){
+
+ push(@database_table_list, decode_utf8($table_name[0]));
+
+ }
+
+ my $table_prefix = $options{"TablePrefix"};
+
+ # Find all the database information tables with the correct table prefix.
+
+ @database_table_list = grep /^$table_prefix/ , @database_table_list;
+ @database_table_list = grep /m*database_info$/ , @database_table_list;
+
+ foreach $table (@database_table_list){
+
+ # Process each table name removing the table prefix name and
+ # the _database_info part.
+
+ $table =~ s/^$table_prefix(_)//g;
+ $table =~ s/_database_info$//g;
+
+ push (@final_table_list, $table);
+
+ }
+
+ # Return the final list of databases.
+
+ return @final_table_list;
+
+}
+
+sub getseconddatabaseinfo{
+#################################################################################
+# getseconddatabaseinfo: Get information about the database that pages will be #
+# moved or copied to. #
+# #
+# Usage: #
+# #
+# $dbmodule->getseconddatabaseinfo(); #
+#################################################################################
+
+
+ # Get the database information.
+
+ my $class = shift;
+ my ($databaseinfo, %databaseinfo);
+ my ($sqldata, @sqldata);
+
+ $error = "";
+ $errorext = "";
+
+ $string_handle = $database_handle->prepare('SELECT name, description, notes, categories, kiriwrite_version_major, kiriwrite_version_minor, kiriwrite_version_revision FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($second_database_filename) . '_database_info LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ @sqldata = $string_handle->fetchrow_array();
+
+ # Process the database information into a hash.
+
+ %databaseinfo = (
+ "DatabaseName" => decode_utf8($sqldata[0]),
+ "Description" => decode_utf8($sqldata[1]),
+ "Notes" => decode_utf8($sqldata[2]),
+ "Categories" => decode_utf8($sqldata[3]),
+ "Major" => decode_utf8($sqldata[4]),
+ "Minor" => decode_utf8($sqldata[5]),
+ "Revision" => decode_utf8($sqldata[6])
+ );
+
+ $string_handle->finish();
+
+ return %databaseinfo;
+
+}
+
+sub selectdb{
+#################################################################################
+# selectdb: Selects the Kiriwrite database. #
+# #
+# Usage: #
+# #
+# $dbmodule->connect(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# DatabaseName Specifies the Kiriwrite database to use. #
+#################################################################################
+
+ # Get the database name.
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my $dbname = $passedoptions->{"DatabaseName"};
+
+ my $database_exists = $class->dbexists($dbname);
+
+ if ($database_exists eq 1){
+
+ # The database does not exist so return an error value
+ # saying that the database does not exist.
+
+ $error = "DoesNotExist";
+
+ return;
+
+ }
+
+ $database_filename = $dbname;
+
+}
+
+sub selectseconddb{
+#################################################################################
+# selectseconddb: Selects a second Kiriwrite database for moving and copying #
+# pages to. #
+# #
+# Usage: #
+# #
+# $dbmodule->selectseconddb(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# DatabaseName Specifies the Kiriwrite database to use. #
+#################################################################################
+
+ # Get the database name.
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+ my (%database, $database);
+
+ my $dbname = $passedoptions->{"DatabaseName"};
+
+ # Check if the database exists.
+
+ my $database_exists = $class->dbexists($dbname);
+
+ if ($database_exists eq 1){
+
+ # The database does not exist so return an error value
+ # saying that the database does not exist.
+
+ $error = "DoesNotExist";
+
+ return;
+
+ }
+
+ # Set the second database filename.
+
+ $second_database_filename = $dbname;
+
+}
+
+sub getdatabaseinfo{
+#################################################################################
+# getdatabaseinfo: Get information about the database. #
+# #
+# Usage: #
+# #
+# $dbmodule->getdatabaseinfo(); #
+#################################################################################
+
+ # Get the database information.
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($databaseinfo, %databaseinfo);
+ my ($sqldata, @sqldata);
+
+ $string_handle = $database_handle->prepare('SELECT name, description, notes, categories, kiriwrite_version_major, kiriwrite_version_minor, kiriwrite_version_revision FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_info LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ @sqldata = $string_handle->fetchrow_array();
+
+ # Process the database information into a hash.
+
+ %databaseinfo = (
+
+ "DatabaseName" => decode_utf8($sqldata[0]),
+ "Description" => decode_utf8($sqldata[1]),
+ "Notes" => decode_utf8($sqldata[2]),
+ "Categories" => decode_utf8($sqldata[3]),
+ "Major" => decode_utf8($sqldata[4]),
+ "Minor" => decode_utf8($sqldata[5]),
+ "Revision" => decode_utf8($sqldata[6])
+ );
+
+ $string_handle->finish();
+
+ return %databaseinfo;
+
+}
+
+sub adddatabase{
+#################################################################################
+# adddatabase: Adds a Kiriwrite database. #
+# #
+# Usage: #
+# #
+# $dbmodule->adddatabase(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# DatabaseFilename Specifies the database file/shortname to use. #
+# DatabaseName Specifies the database name to use. #
+# DatabaseDescription Specifies the database description to use. #
+# DatabaseNotes Specifies the database notes to use. #
+# DatabaseCategories Specifies the database categories to use. #
+# VersionMajor Specifies the major version. #
+# VersionMinor Specifies the minor version. #
+# VersionRevision Specifies the revision version. #
+#################################################################################
+
+ # Get the database that was passed to the subroutine.
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my $dbfilename = $passedoptions->{"DatabaseFilename"};
+ my $dbname = $passedoptions->{"DatabaseName"};
+ my $dbdescription = $passedoptions->{"DatabaseDescription"};
+ my $dbnotes = $passedoptions->{"DatabaseNotes"};
+ my $dbcategories = $passedoptions->{"DatabaseCategories"};
+ my $dbmajorver = $passedoptions->{"VersionMajor"};
+ my $dbminorver = $passedoptions->{"VersionMinor"};
+ my $dbrevisionver = $passedoptions->{"VersionRevision"};
+
+ # Check if the database with the filename given already exists.
+
+ my $database_exists = $class->dbexists($dbfilename);
+
+ if ($database_exists eq 0){
+
+ # The database filename exists so set the error value.
+
+ $error = "DatabaseExists";
+ return;
+
+ }
+
+ # Create the database structure (info and page tables);
+
+ $string_handle = $database_handle->prepare('CREATE TABLE ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($dbfilename) . '_database_info (
+ name varchar(256) primary key,
+ description varchar(512),
+ notes mediumtext,
+ categories varchar(512),
+ kiriwrite_version_major int(4),
+ kiriwrite_version_minor int(4),
+ kiriwrite_version_revision int(4)
+ ) DEFAULT CHARSET=utf8') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ $string_handle = $database_handle->prepare('CREATE TABLE ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($dbfilename) . '_database_pages (
+ filename varchar(256) primary key,
+ pagename varchar(512),
+ pagedescription varchar(512),
+ pagesection varchar(256),
+ pagetemplate varchar(64),
+ pagedata mediumtext,
+ pagesettings int(1),
+ lastmodified datetime
+ ) DEFAULT CHARSET=utf8') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Convert the values into SQL query formatted values and add an entry
+ # to the kiriwrite_database_info table.
+
+ $string_handle = $database_handle->prepare('INSERT INTO ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($dbfilename) . '_database_info (name, description, notes, categories, kiriwrite_version_major, kiriwrite_version_minor, kiriwrite_version_revision) VALUES(
+ \'' . $class->convert($dbname) . '\',
+ \'' . $class->convert($dbdescription) . '\',
+ \'' . $class->convert($dbnotes) . '\',
+ \'' . $class->convert($dbcategories) . '\',
+ \'' . $class->convert($dbmajorver) . '\',
+ \'' . $class->convert($dbminorver) . '\',
+ \'' . $class->convert($dbrevisionver) . '\'
+ )') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub editdatabase{
+#################################################################################
+# editdatabase: Edits a Kiriwrite Database. #
+# #
+# Usage: #
+# #
+# $dbmodule->editdatabase(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# NewDatabaseFilename Specifies the new database filename to use. #
+# DatabaseName Specifies the new database name. #
+# DatabaseDescription Specifies the new database description. #
+# DatabaseNotes Specifies the new database notes. #
+# DatabaseCategories Specifies the new database categories. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my $dbnewfilename = $passedoptions->{"DatabaseNewFilename"};
+ my $dbname = $passedoptions->{"DatabaseName"};
+ my $dbdescription = $passedoptions->{"DatabaseDescription"};
+ my $dbnotes = $passedoptions->{"DatabaseNotes"};
+ my $dbcategories = $passedoptions->{"DatabaseCategories"};
+
+ # Check if a new database filename has been specified and if a
+ # new database filename has been specified then change the
+ # database filename.
+
+ if ($database_filename ne $dbnewfilename){
+
+ # Check if a table with the filename already exists before using the
+ # new filename.
+
+ my $database_newexists = $class->dbexists($dbnewfilename);
+
+ if ($database_newexists eq 0){
+
+ # The database filename exists so set the error value.
+
+ $error = "DatabaseExists";
+ return;
+
+ }
+
+ # Rename the tables.
+
+ $string_handle = $database_handle->prepare('RENAME TABLE ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_info TO ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($dbnewfilename) . '_database_info, ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages TO ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($dbnewfilename) . '_database_pages');
+ $string_handle->execute();
+
+ }
+
+ # Get the current database information.
+
+ $string_handle = $database_handle->prepare('SELECT name FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($dbnewfilename) . '_database_info LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ my @database_oldinfo = $string_handle->fetchrow_array();
+
+ my $dboldname = decode_utf8($database_oldinfo[0]);
+
+ # Update the database information.
+
+ $string_handle = $database_handle->prepare('UPDATE ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($dbnewfilename) . '_database_info SET name = \'' . $class->convert($dbname) . '\',
+ description = \'' . $class->convert($dbdescription) . '\',
+ notes = \'' . $class->convert($dbnotes) . '\',
+ categories = \'' . $class->convert($dbcategories) . '\'') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub deletedatabase{
+#################################################################################
+# deletedatabase: Deletes a Kiriwrite database. #
+# #
+# Usage: #
+# #
+# $dbmodule->deletedatabase(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# DatabaseName Specifies the Kiriwrite database to delete. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the database filename.
+
+ my $class = shift;
+ my ($passedoptions) = shift;
+
+ my $databasename = $passedoptions->{"DatabaseName"};
+
+ my @table_data;
+ my $table_exists;
+
+ # Check if the database with the filename given already exists.
+
+ my $database_exists = $class->dbexists($databasename);
+
+ if ($database_exists eq 1){
+
+ # The database does not exist so set the error value.
+
+ $error = "DoesNotExist";
+ return;
+
+ }
+
+
+
+ # Delete the database tables.
+
+ $string_handle = $database_handle->prepare('DROP TABLE ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($databasename) . '_database_info') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if the _database_pages table exists and delete it if it exists.
+
+ $string_handle = $database_handle->prepare('SHOW TABLES LIKE \'' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($databasename) . '_database_pages\'') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@table_data = $string_handle->fetchrow_array()){
+
+ $table_exists = 1;
+
+ }
+
+ # Check if the _database_pages table really does exist.
+
+ if ($table_exists eq 1){
+
+ # the _database_pages table really does exist so delete it.
+
+ $string_handle = $database_handle->prepare('DROP TABLE ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($databasename) . '_database_pages') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ }
+
+}
+
+#################################################################################
+# Template subroutines. #
+#################################################################################
+
+sub connecttemplate{
+#################################################################################
+# connecttemplate: Connect to the template database. #
+# #
+# Usage: #
+# #
+# $dbmodule->connecttemplate(missingignore); #
+# #
+# missingignore Ignore errror about database being missing. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my $ignoremissing = shift;
+ my $templatedb_exists = 0;
+ my @templatedb_check;
+
+ # Check if the template database exists.
+
+ $string_handle = $database_handle->prepare('SHOW TABLES LIKE \'' . $class->convert($options{"TablePrefix"}) . '_templates\'') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@templatedb_check = $string_handle->fetchrow_array()){
+
+ $templatedb_exists = 1;
+
+ }
+
+ if (!$templatedb_exists){
+
+ if (!$ignoremissing){
+
+ $error = "TemplateDatabaseDoesNotExist";
+ return;
+
+ }
+
+ }
+
+}
+
+sub disconnecttemplate{
+#################################################################################
+# disconnecttemplate: Disconnect from the template database. #
+# #
+# Usage: #
+# #
+# $dbmodule->disconnecttemplate(); #
+#################################################################################
+
+ # This subroutine is not used.
+
+}
+
+sub gettemplatelist{
+#################################################################################
+# gettemplatelist: Gets the list of templates. #
+# #
+# Usage: #
+# #
+# $dbmodule->gettemplatelist(); #
+#################################################################################
+
+ my $error = "";
+ my $errorext = "";
+
+ my $class = shift;
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM ' . $class->convert($options{"TablePrefix"}) . '_templates ORDER BY filename ASC') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ my @database_template;
+ my @templates_list;
+ my $template_filename;
+
+ while (@database_template = $string_handle->fetchrow_array()){
+
+ # Get certain values from the array.
+
+ $template_filename = decode_utf8($database_template[0]);
+
+ # Add the template to the list of templates.
+
+ push(@templates_list, $template_filename);
+
+ }
+
+ return @templates_list;
+
+}
+
+sub gettemplateinfo{
+#################################################################################
+# gettemplateinfo: Get information on a template. #
+# #
+# Usage: #
+# #
+# $dbmodule->gettemplateinfo(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# TemplateFilename Specifies the template filename to use. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my %page_info;
+ my @template_data;
+
+ my $template_filename;
+ my $template_name;
+ my $template_description;
+ my $template_datemodified;
+ my $template_layout;
+
+ my $template_found = 0;
+
+ my $filename = $passedoptions->{"TemplateFilename"};
+
+ $string_handle = $database_handle->prepare('SELECT filename, templatename, templatedescription, templatelayout, datemodified FROM ' . $class->convert($options{"TablePrefix"}) . '_templates WHERE filename = \'' . $class->convert($filename) . '\'') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@template_data = $string_handle->fetchrow_array()){
+
+ # Get certain values from the array.
+
+ $template_filename = decode_utf8($template_data[0]);
+ $template_name = decode_utf8($template_data[1]);
+ $template_description = decode_utf8($template_data[2]);
+ $template_layout = decode_utf8($template_data[3]);
+ $template_datemodified = decode_utf8($template_data[4]);
+
+ # Process them into the hash.
+
+ %page_info = (
+ "TemplateFilename" => $template_filename,
+ "TemplateName" => $template_name,
+ "TemplateDescription" => $template_description,
+ "TemplateLayout" => $template_layout,
+ "TemplateLastModified" => $template_datemodified
+ );
+
+ $template_found = 1;
+
+ }
+
+ if ($template_found eq 0){
+
+ # The template was not found in the template database so
+ # write an error value.
+
+ $error = "TemplateDoesNotExist";
+ return;
+
+ }
+
+ return %page_info;
+
+}
+
+
+sub addtemplate{
+#################################################################################
+# addtemplate: Adds a template to the template database. #
+# #
+# Usage: #
+# #
+# $dbmodule->addtemplate(); #
+# #
+# options Specifies the following options in any order. #
+# #
+# TemplateFilename Specifies the new template filename. #
+# TemplateName Specifies the new template name. #
+# TemplateDescription Specifies the new template description. #
+# TemplateLayout Specifies the new template layout. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my @page_exists;
+ my @templatedb_check;
+ my $templatedb_exists;
+ my $blankfile = 0;
+
+ my $template_filename = $passedoptions->{"TemplateFilename"};
+ my $template_name = $passedoptions->{"TemplateName"};
+ my $template_description = $passedoptions->{"TemplateDescription"};
+ my $template_layout = $passedoptions->{"TemplateLayout"};
+
+ # Check if the template database exists.
+
+ $string_handle = $database_handle->prepare('SHOW TABLES LIKE \'' . $class->convert($options{"TablePrefix"}) . '_templates\'') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@templatedb_check = $string_handle->fetchrow_array()){
+
+ $templatedb_exists = 1;
+
+ }
+
+ # Check if the template database table exists and if it doesn't
+ # then create the template database table.
+
+ if (!$templatedb_exists){
+
+ $string_handle = $database_handle->prepare('CREATE TABLE ' . $class->convert($options{"TablePrefix"}) . '_templates (
+ filename varchar(256) primary key,
+ templatename varchar(512),
+ templatedescription varchar(512),
+ templatelayout mediumtext,
+ datemodified datetime
+ ) DEFAULT CHARSET=utf8') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ }
+
+ # Check if the template already exists before adding.
+
+ if (!$templatedb_exists){
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM ' . $class->convert($options{"TablePrefix"}) . '_templates WHERE filename = \'' . $class->convert($template_filename) . '\' LIMIT 1') or ($blankfile = 1);
+
+ if ($blankfile eq 0){
+
+ $string_handle->execute();
+
+ while (@page_exists = $string_handle->fetchrow_array()){
+
+ $error = "TemplatePageExists";
+ return;
+
+ }
+
+ }
+
+ }
+
+ # Get the current date.
+
+ my ($created_second, $created_minute, $created_hour, $created_day, $created_month, $created_year, $created_weekday, $created_yearday, $created_dst) = localtime;
+
+ my $template_date = $created_year . '-' . $created_month . '-' . $created_day . ' ' . $created_hour . ':' . $created_minute . ':' . $created_second;
+
+ # Check if certain values are undefined and if they
+ # are then set them blank.
+
+ if (!$template_name){
+
+ $template_name = "";
+
+ }
+
+ if (!$template_description){
+
+ $template_description = "";
+
+ }
+
+ if (!$template_layout){
+
+ $template_layout = "";
+
+ }
+
+ $string_handle = $database_handle->prepare('INSERT INTO ' . $class->convert($options{"TablePrefix"}) . '_templates (filename, templatename, templatedescription, templatelayout, datemodified) VALUES(
+ \'' . $class->convert($template_filename) . '\',
+ \'' . $class->convert($template_name) . '\',
+ \'' . $class->convert($template_description) . '\',
+ \'' . $class->convert($template_layout) . '\',
+ \'' . $class->convert($template_date) . '\'
+ )') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub deletetemplate{
+#################################################################################
+# deletetemplate: Deletes a template from the template database. #
+# #
+# Usage: #
+# #
+# $dbmodule->deletetemplate(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# TemplateFilename Specifies the template filename to delete. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my @pagedata;
+ my $template_filename = $passedoptions->{"TemplateFilename"};
+ my $template_count = 0;
+
+ # Check if the template exists.
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM ' . $class->convert($options{"TablePrefix"}) . '_templates WHERE filename = \'' . $class->convert($template_filename) . '\' LIMIT 1') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@pagedata = $string_handle->fetchrow_array()){
+
+ $template_count++;
+
+ }
+
+ if ($template_count eq 0){
+
+ # No pages were returned so return an error value.
+
+ $error = "TemplateDoesNotExist";
+ return;
+
+ }
+
+ # Delete the template from the template database.
+
+ $string_handle = $database_handle->prepare('DELETE FROM ' . $class->convert($options{"TablePrefix"}) . '_templates WHERE filename = \'' . $class->convert($template_filename) . '\'') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub edittemplate{
+#################################################################################
+# editttemplate: Edits a Kiriwrite template. #
+# #
+# Usage: #
+# #
+# $dbmodule->edittemplate(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# TemplateFilename Specifies the template filename to edit. #
+# NewTemplateFilename Specifies the new template filename. #
+# NewTemplateName Specifies the new template name. #
+# NewTemplateDescription Specifies the new template description. #
+# NewTemplateLayout Specifies the new template layout. #
+#################################################################################
+
+ # Get the values passed.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+ my $template_found = 0;
+ my @template_info;
+
+ # Process the values passed.
+
+ my $template_filename = $passedoptions->{"TemplateFilename"};
+ my $new_template_filename = $passedoptions->{"NewTemplateFilename"};
+ my $new_template_name = $passedoptions->{"NewTemplateName"};
+ my $new_template_description = $passedoptions->{"NewTemplateDescription"};
+ my $new_template_layout = $passedoptions->{"NewTemplateLayout"};
+
+ # Check if the template exists.
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM ' . $class->convert($options{"TablePrefix"}) . '_templates WHERE filename = \'' . $class->convert($template_filename) . '\' LIMIT 1') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@template_info = $string_handle->fetchrow_array()){
+
+ $template_found = 1;
+
+ }
+
+ # Check to see if the template was found and set an error value if
+ # it wasn't.
+
+ if ($template_found eq 0){
+
+ $error = "TemplateDoesNotExist";
+ return;
+
+ }
+
+ # Get the date and time.
+
+ my ($created_second, $created_minute, $created_hour, $created_day, $created_month, $created_year, $created_weekday, $created_yearday, $created_dst) = localtime;
+ my $templatenewdate = $created_year . '-' . $created_month . '-' . $created_day . ' ' . $created_hour . ':' . $created_minute . ':' . $created_second;
+
+ # Update the template information.
+
+ $string_handle = $database_handle->prepare('UPDATE ' . $class->convert($options{"TablePrefix"}) . '_templates SET
+ filename = \'' . $class->convert($new_template_filename) . '\',
+ templatename = \'' . $class->convert($new_template_name) . '\',
+ templatedescription = \'' . $class->convert($new_template_description) . '\',
+ templatelayout = \'' . $class->convert($new_template_layout) . '\',
+ datemodified = \'' . $class->convert($templatenewdate) . '\'
+ WHERE filename = \'' . $class->convert($template_filename) . '\'
+ ') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+#################################################################################
+# Page subroutines. #
+#################################################################################
+
+sub getpagelist{
+#################################################################################
+# getpagelist: Gets the list of pages from the database. #
+# #
+# Usage: #
+# #
+# $dbmodule->getpagelist(); #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ my @database_pagefilenames;
+ my @database_pagefilenames_final;
+
+ # Process the collected pages.
+
+ while (@database_pagefilenames = $string_handle->fetchrow_array){
+
+ # Add each page to the list of pages in the database.
+
+ push(@database_pagefilenames_final, decode_utf8($database_pagefilenames[0]));
+
+ }
+
+ return @database_pagefilenames_final;
+
+}
+
+sub getpageinfo{
+#################################################################################
+# getpageinfo: Gets the page information from the filename passed. #
+# #
+# Usage: #
+# #
+# $dbmodule->getpageinfo(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the page filename to get the page information from. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = shift;
+ my (%database_page, $database_page);
+ my ($pagefilename, $pagename, $pagedescription, $pagesection, $pagetemplate, $pagedata, $pagesettings, $pagelastmodified);
+
+ my @data_page;
+ my $page_found = 0;
+
+ # Get the page from the database.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+
+ $string_handle = $database_handle->prepare('SELECT filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if the page exists in the database.
+
+ while (@data_page = $string_handle->fetchrow_array()){
+
+ # Get the values from the array.
+
+ $pagefilename = decode_utf8($data_page[0]);
+ $pagename = decode_utf8($data_page[1]);
+ $pagedescription = decode_utf8($data_page[2]);
+ $pagesection = decode_utf8($data_page[3]);
+ $pagetemplate = decode_utf8($data_page[4]);
+ $pagedata = decode_utf8($data_page[5]);
+ $pagesettings = decode_utf8($data_page[6]);
+ $pagelastmodified = decode_utf8($data_page[7]);
+
+ # Put the values into the page hash.
+
+ %database_page = (
+ "PageFilename" => $pagefilename,
+ "PageName" => $pagename,
+ "PageDescription" => $pagedescription,
+ "PageSection" => $pagesection,
+ "PageTemplate" => $pagetemplate,
+ "PageContent" => $pagedata,
+ "PageSettings" => $pagesettings,
+ "PageLastModified" => $class->dateconvert($pagelastmodified),
+ );
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page did exist.
+
+ if (!$page_found){
+
+ $error = "PageDoesNotExist";
+ return;
+
+ }
+
+ return %database_page;
+
+}
+
+
+sub addpage{
+#################################################################################
+# addpage: Add a page to the selected database. #
+# #
+# Usage: #
+# #
+# $dbmodule->addpage(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the page filename to use. #
+# PageName Specifies the page name to use. #
+# PageDescription Specifies the page description to use. #
+# PageSection Specifies the page section to use. #
+# PageTemplate Specifies the page template to use. #
+# PageContent Specifies the page content to use. #
+# PageSettings Specifies the page settings to use. #
+#################################################################################
+
+ # Get the data that was passed to the subroutine.
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = shift;
+
+ my @database_page;
+ my $page_count = 0;
+
+ # Get the values passed to the hash.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+ my $page_name = $passedoptions->{"PageName"};
+ my $page_description = $passedoptions->{"PageDescription"};
+ my $page_section = $passedoptions->{"PageSection"};
+ my $page_template = $passedoptions->{"PageTemplate"};
+ my $page_content = $passedoptions->{"PageContent"};
+ my $page_settings = $passedoptions->{"PageSettings"};
+
+ # Check to see if the filename given already exists
+ # in the page database.
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if a page with the filename given really does
+ # exist.
+
+ while (@database_page = $string_handle->fetchrow_array()){
+
+ # A page does exist so increment the count to 1.
+
+ $page_count++;
+
+ }
+
+ if ($page_count ne 0){
+
+ # The page does exist so set the error value.
+
+ $error = "PageExists";
+ return;
+
+ }
+
+ # Check if certain values are undefined.
+
+ if (!$page_name){
+
+ $page_name = "";
+
+ }
+
+ if (!$page_description){
+
+ $page_description = "";
+
+ }
+
+ if (!$page_section){
+
+ $page_section = "";
+
+ }
+
+ if (!$page_content){
+
+ $page_content = "";
+
+ }
+
+ my ($created_second, $created_minute, $created_hour, $created_day, $created_month, $created_year, $created_weekday, $created_yearday, $created_dst) = localtime;
+ my $page_date = $created_year . '-' . $created_month . '-' . $created_day . ' ' . $created_hour . ':' . $created_minute . ':' . $created_second;
+
+ # Add the page to the selected database.
+
+ $string_handle = $database_handle->prepare('INSERT INTO ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages (filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified) VALUES (
+ \'' . $class->convert($page_filename) . '\',
+ \'' . $class->convert($page_name) . '\',
+ \'' . $class->convert($page_description) . '\',
+ \'' . $class->convert($page_section) . '\',
+ \'' . $class->convert($page_template) . '\',
+ \'' . $class->convert($page_content) . '\',
+ \'' . $class->convert($page_settings) . '\',
+ \'' . $class->convert($page_date) . '\'
+ )') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub deletepage{
+#################################################################################
+# deletepage: Delete a page from the selected database. #
+# #
+# Usage: #
+# #
+# $dbmodule->deletepage(options) #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the page filename to delete. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the data that was passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+ my @page_info;
+ my $page_found = 0;
+
+ # Get the page filename.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+
+ # Check if the page exists before deleting it.
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@page_info = $string_handle->fetchrow_array()){
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if (!$page_found){
+
+ $error = "PageDoesNotExist";
+ return;
+
+ }
+
+ # Delete the page.
+
+ $string_handle = $database_handle->prepare('DELETE FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\'') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub editpage{
+#################################################################################
+# editpage: Edit a page from the selected database. #
+# #
+# Usage: #
+# #
+# $dbmodule->editpage(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the filename to edit. #
+# PageNewFilename Specifies the new filename to use. #
+# PageNewName Specifies the new page name to use. #
+# PageNewDescription Specifies the new page description to use. #
+# PageNewSection Specifies the new page section to use. #
+# PageNewTemplate Specifies the new page template to use. #
+# PageNewContent Specifies the new page content to use. #
+# PageNewSettings Specifies the new page settings to use. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+ my $page_found = 0;
+ my @page_info;
+
+ # Get the data that was passed to the subroutine.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+ my $page_newfilename = $passedoptions->{"PageNewFilename"};
+ my $page_newname = $passedoptions->{"PageNewName"};
+ my $page_newdescription = $passedoptions->{"PageNewDescription"};
+ my $page_newsection = $passedoptions->{"PageNewSection"};
+ my $page_newtemplate = $passedoptions->{"PageNewTemplate"};
+ my $page_newcontent = $passedoptions->{"PageNewContent"};
+ my $page_newsettings = $passedoptions->{"PageNewSettings"};
+
+ # Check if the page with the filename given exists.
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if the page really does exist.
+
+ while (@page_info = $string_handle->fetchrow_array()){
+
+ # The page information is found.
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if (!$page_found){
+
+ $error = "PageDoesNotExist";
+ return;
+
+ }
+
+ # Get the current date.
+
+ my ($created_second, $created_minute, $created_hour, $created_day, $created_month, $created_year, $created_weekday, $created_yearday, $created_dst) = localtime;
+ my $page_date = $created_year . '-' . $created_month . '-' . $created_day . ' ' . $created_hour . ':' . $created_minute . ':' . $created_second;
+
+ # Edit the selected page.
+
+ $string_handle = $database_handle->prepare('UPDATE ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages SET filename = \'' . $class->convert($page_newfilename) . '\', pagename = \'' . $class->convert($page_newname) . '\', pagedescription = \'' . $class->convert($page_newdescription) . '\', pagesection = \'' . $class->convert($page_newsection) . '\', pagetemplate = \'' . $class->convert($page_newtemplate) . '\', pagedata = \'' . $class->convert($page_newcontent) . '\', pagedata = \'' . $class->convert($page_newcontent) . '\', pagesettings = \'' . $class->convert($page_newsettings) . '\', lastmodified = \'' . $page_date . '\' WHERE filename = \'' . $class->convert($page_filename) . '\'') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub movepage{
+#################################################################################
+# movepage: Moves a page from the old database to the new database. #
+# #
+# Usage: #
+# #
+# $dbmodule->movepage(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the page with the filename to move. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my (%database_page, $database_page);
+ my ($pagefilename, $pagename, $pagedescription, $pagesection, $pagetemplate, $pagedata, $pagesettings, $pagelastmodified);
+ my @page_info;
+ my $page_found = 0;
+
+ # Get the data that was passed to the subroutine.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+
+ # Check if the page with the filename given exists.
+
+ $string_handle = $database_handle->prepare('SELECT filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "OldDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if the page really does exist.
+
+ while (@page_info = $string_handle->fetchrow_array()){
+
+ # Get the values from the array.
+
+ $pagefilename = decode_utf8($page_info[0]);
+ $pagename = decode_utf8($page_info[1]);
+ $pagedescription = decode_utf8($page_info[2]);
+ $pagesection = decode_utf8($page_info[3]);
+ $pagetemplate = decode_utf8($page_info[4]);
+ $pagedata = decode_utf8($page_info[5]);
+ $pagesettings = decode_utf8($page_info[6]);
+ $pagelastmodified = decode_utf8($page_info[7]);
+
+ # Put the values into the page hash.
+
+ %database_page = (
+ "PageFilename" => $pagefilename,
+ "PageName" => $pagename,
+ "PageDescription" => $pagedescription,
+ "PageSection" => $pagesection,
+ "PageTemplate" => $pagetemplate,
+ "PageContent" => $pagedata,
+ "PageSettings" => $pagesettings,
+ "PageLastModified" => $pagelastmodified,
+ );
+
+ # The page information is found.
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if (!$page_found){
+
+ $error = "PageDoesNotExist";
+ return;
+
+ }
+
+ # Check if the page with the filename given already exists in
+ # the database the page is being moved to.
+
+ $page_found = 0;
+ @page_info = ();
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($second_database_filename) . '_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "NewDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@page_info = $string_handle->fetchrow_array()){
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if ($page_found){
+
+ $error = "PageAlreadyExists";
+ return;
+
+ }
+
+ # Add the page to the new database.
+
+ $string_handle = $database_handle->prepare('INSERT INTO ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($second_database_filename) . '_database_pages (filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified) VALUES (
+ \'' . $class->convert($database_page{"PageFilename"}) . '\',
+ \'' . $class->convert($database_page{"PageName"}) . '\',
+ \'' . $class->convert($database_page{"PageDescription"}) . '\',
+ \'' . $class->convert($database_page{"PageSection"}) . '\',
+ \'' . $class->convert($database_page{"PageTemplate"}) . '\',
+ \'' . $class->convert($database_page{"PageContent"}) . '\',
+ \'' . $class->convert($database_page{"PageSettings"}) . '\',
+ \'' . $class->convert($database_page{"PageLastModified"}) . '\'
+ )') or ( $error = "NewDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Delete the page from the old database.
+
+ $string_handle = $database_handle->prepare('DELETE FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages WHERE filename = \'' . $class->convert($database_page{"PageFilename"}) . '\'') or ( $error = "OldDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub copypage{
+#################################################################################
+# copypage: Copies a page from the old database to the new database. #
+# #
+# Usage: #
+# #
+# $dbmodule->copypage(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the page with the filename to copy. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my (%database_page, $database_page);
+ my ($pagefilename, $pagename, $pagedescription, $pagesection, $pagetemplate, $pagedata, $pagesettings, $pagelastmodified);
+ my @page_info;
+ my $page_found = 0;
+
+ # Get the data that was passed to the subroutine.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+
+ # Check if the page with the filename given exists.
+
+ $string_handle = $database_handle->prepare('SELECT filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($database_filename) . '_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "OldDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if the page really does exist.
+
+ while (@page_info = $string_handle->fetchrow_array()){
+
+ # Get the values from the array.
+
+ $pagefilename = decode_utf8($page_info[0]);
+ $pagename = decode_utf8($page_info[1]);
+ $pagedescription = decode_utf8($page_info[2]);
+ $pagesection = decode_utf8($page_info[3]);
+ $pagetemplate = decode_utf8($page_info[4]);
+ $pagedata = decode_utf8($page_info[5]);
+ $pagesettings = decode_utf8($page_info[6]);
+ $pagelastmodified = decode_utf8($page_info[7]);
+
+ # Put the values into the page hash.
+
+ %database_page = (
+ "PageFilename" => $pagefilename,
+ "PageName" => $pagename,
+ "PageDescription" => $pagedescription,
+ "PageSection" => $pagesection,
+ "PageTemplate" => $pagetemplate,
+ "PageContent" => $pagedata,
+ "PageSettings" => $pagesettings,
+ "PageLastModified" => $pagelastmodified,
+ );
+
+ # The page information is found.
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if (!$page_found){
+
+ $error = "PageDoesNotExist";
+ return;
+
+ }
+
+ # Check if the page with the filename given already exists in
+ # the database the page is being moved to.
+
+ $page_found = 0;
+ @page_info = ();
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($second_database_filename) . '_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "NewDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@page_info = $string_handle->fetchrow_array()){
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if ($page_found){
+
+ $error = "PageAlreadyExists";
+ return;
+
+ }
+
+ # Add the page to the new database.
+
+ $string_handle = $database_handle->prepare('INSERT INTO ' . $class->convert($options{"TablePrefix"}) . '_' . $class->convert($second_database_filename) . '_database_pages (filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified) VALUES (
+ \'' . $class->convert($database_page{"PageFilename"}) . '\',
+ \'' . $class->convert($database_page{"PageName"}) . '\',
+ \'' . $class->convert($database_page{"PageDescription"}) . '\',
+ \'' . $class->convert($database_page{"PageSection"}) . '\',
+ \'' . $class->convert($database_page{"PageTemplate"}) . '\',
+ \'' . $class->convert($database_page{"PageContent"}) . '\',
+ \'' . $class->convert($database_page{"PageSettings"}) . '\',
+ \'' . $class->convert($database_page{"PageLastModified"}) . '\'
+ )') or ( $error = "NewDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+#################################################################################
+# Filter subroutines. #
+#################################################################################
+
+sub connectfilter{
+#################################################################################
+# connectfilter: Connect to the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->connectfilter(missingignore); #
+# #
+# missingignore Ignore error about database being missing. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my $ignoremissing = shift;
+ my @filterdb_check;
+ my $filterdb_exists = 0;
+
+ # Check if the template database exists.
+
+ $string_handle = $database_handle->prepare('SHOW TABLES LIKE \'' . $class->convert($options{"TablePrefix"}) . '_filters\'') or ( $error = "TemplateDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@filterdb_check = $string_handle->fetchrow_array()){
+
+ $filterdb_exists = 1;
+
+ }
+
+ if (!$filterdb_exists){
+
+ if (!$ignoremissing){
+
+ $error = "FilterDatabaseDoesNotExist";
+ return;
+
+ }
+
+ }
+
+}
+
+sub disconnectfilter{
+#################################################################################
+# disconnectfilter: Disconnect from the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->disconnectfilter(); #
+#################################################################################
+
+ # This subroutine is not used.
+
+}
+
+sub getfilterlist{
+#################################################################################
+# getfilterlist: Gets the list of filters in the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->getfilterlist(); #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+
+ my @filter_list;
+ my @filter_data;
+
+ # Get the list of filters available.
+
+ $string_handle = $database_handle->prepare('SELECT id, priority FROM ' . $class->convert($options{"TablePrefix"}) . '_filters ORDER BY priority ASC') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@filter_data = $string_handle->fetchrow_array()){
+
+ # Add the filter to the list of available filters.
+
+ push(@filter_list, decode_utf8($filter_data[0]));
+
+ }
+
+ return @filter_list;
+
+}
+
+sub getfilterinfo{
+#################################################################################
+# getfilterinfo: Gets information about the filter. #
+# #
+# Usage: #
+# #
+# $dbmodule->getfilterinfo(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# FilterID Specifies the filter ID number to get information from. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my %filter_info;
+ my $filter_exists = 0;
+ my @filter_data;
+
+ # Get the values that are in the hash.
+
+ my $filter_id = $passedoptions->{"FilterID"};
+
+ $string_handle = $database_handle->prepare('SELECT id, priority, findsetting, replacesetting, notes FROM ' . $class->convert($options{"TablePrefix"}) . '_filters where id = \'' . $class->convert($filter_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Get the filter information.
+
+ while (@filter_data = $string_handle->fetchrow_array()){
+
+ $filter_info{"FilterID"} = decode_utf8($filter_data[0]);
+ $filter_info{"FilterPriority"} = decode_utf8($filter_data[1]);
+ $filter_info{"FilterFind"} = decode_utf8($filter_data[2]);
+ $filter_info{"FilterReplace"} = decode_utf8($filter_data[3]);
+ $filter_info{"FilterNotes"} = decode_utf8($filter_data[4]);
+
+ $filter_exists = 1;
+
+ }
+
+ # Check if the filter exists.
+
+ if (!$filter_exists){
+
+ # The filter does not exist so return
+ # an error value.
+
+ $error = "FilterDoesNotExist";
+ return;
+
+ }
+
+ # Return the filter information.
+
+ return %filter_info;
+
+}
+
+sub addfilter{
+#################################################################################
+# addfilter: Adds a filter to the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->addfilter(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# FindFilter Specifies the find filter to add. #
+# ReplaceFilter Specifies the replace filter to add. #
+# Priority Specifies the filter priority to use. #
+# Notes Specifies the notes to use. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ # Define some variables for later.
+
+ my @database_filters;
+ my @filterdb_check;
+ my @filterid_list;
+ my @filterid_check;
+ my $nofiltertable = 0;
+ my $filter_found = 0;
+ my $filter_count = 0;
+ my $filterdb_exists = 0;
+ my $filter_id;
+ my $new_id;
+
+ # Get the values from the hash.
+
+ my $filter_find = $passedoptions->{"FindFilter"};
+ my $filter_replace = $passedoptions->{"ReplaceFilter"};
+ my $filter_priority = $passedoptions->{"Priority"};
+ my $filter_notes = $passedoptions->{"Notes"};
+
+ # Check if the template database exists.
+
+ $string_handle = $database_handle->prepare('SHOW TABLES LIKE \'' . $class->convert($options{"TablePrefix"}) . '_filters\'') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@filterdb_check = $string_handle->fetchrow_array()){
+
+ $filterdb_exists = 1;
+
+ }
+
+ # Check if certain values are undefined and if they
+ # are then set them blank.
+
+ if (!$filter_find){
+
+ $filter_find = "";
+
+ }
+
+ if (!$filter_replace){
+
+ $filter_replace = "";
+
+ }
+
+ if (!$filter_priority){
+
+ $filter_priority = 1;
+
+ }
+
+ if (!$filter_notes){
+
+ $filter_notes = "";
+
+ }
+
+ # Check if there is really no filter table.
+
+ if (!$filterdb_exists){
+
+ # Create the filter database table.
+
+ $string_handle = $database_handle->prepare('CREATE TABLE ' . $class->convert($options{"TablePrefix"}) . '_filters (
+ id int(7) primary key,
+ priority int(5),
+ findsetting varchar(1024),
+ replacesetting varchar(1024),
+ notes text
+ ) DEFAULT CHARSET=utf8') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ }
+
+ # Find the lowest filter identification number available.
+
+ $string_handle = $database_handle->prepare('SELECT id FROM ' . $class->convert($options{"TablePrefix"}) . '_filters ORDER BY id ASC') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@database_filters = $string_handle->fetchrow_array()){
+
+ $filter_id = decode_utf8($database_filters[0]);
+
+ # Add the filter identification to the list of filter IDs.
+
+ push(@filterid_list, $filter_id);
+
+ }
+
+ $filter_id = "";
+
+ # Process each filter looking for a blank available filter.
+
+ foreach $filter_id (@filterid_list){
+
+ # Check the next filter ID to see if it's blank.
+
+ $new_id = $filter_id + 1;
+
+ $string_handle = $database_handle->prepare('SELECT id FROM ' . $class->convert($options{"TablePrefix"}) . '_filters WHERE id = \'' . $class->convert($new_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Get the filter identification number.
+
+ while (@filterid_check = $string_handle->fetchrow_array()){
+
+ $filter_found = 1;
+
+ }
+
+ # Check if a filter was found.
+
+ if (!$filter_found){
+
+ # No filter was found using this ID so exit the loop.
+
+ last;
+
+ }
+
+ # Increment the filter count and reset the filter found value.
+
+ $filter_count++;
+ $filter_found = 0;
+ $new_id = 0;
+
+ }
+
+ # Check if there were any filters in the filters database.
+
+ if (!$filter_count && !$new_id){
+
+ # There were no filters in the filters database so set
+ # the new filter identification value to 1.
+
+ $new_id = 1;
+
+ }
+
+ # Add the filter to the filter database.
+
+ $string_handle = $database_handle->prepare('INSERT INTO ' . $class->convert($options{"TablePrefix"}) . '_filters (id, priority, findsetting, replacesetting, notes) VALUES (
+ \'' . $class->convert($new_id) . '\',
+ \'' . $class->convert($filter_priority) . '\',
+ \'' . $class->convert($filter_find) . '\',
+ \'' . $class->convert($filter_replace) .'\',
+ \'' . $class->convert($filter_notes) . '\'
+ )') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+
+sub editfilter{
+#################################################################################
+# editfilter: Edits a filter in the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->editfilter(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# FilterID Specifies the filter to edit. #
+# NewFindFilter Specifies the new find filter setting. #
+# NewReplaceFilter Specifies the new replace filter setting. #
+# NewFilterPriority Specifies the new filter priority setting. #
+# NewFilterNotes Specifies the new notes for the filter. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my @filter_data;
+ my $filter_exists = 1;
+ my $blankfile = 0;
+
+ # Get the values from the hash.
+
+ my $filter_id = $passedoptions->{"FilterID"};
+ my $filter_newfind = $passedoptions->{"NewFindFilter"};
+ my $filter_newreplace = $passedoptions->{"NewReplaceFilter"};
+ my $filter_newpriority = $passedoptions->{"NewFilterPriority"};
+ my $filter_newnotes = $passedoptions->{"NewFilterNotes"};
+
+ # Check if the filter exists before editing it.
+
+ $string_handle = $database_handle->prepare('SELECT id FROM ' . $class->convert($options{"TablePrefix"}) . '_filters where id = \'' . $class->convert($filter_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if the filter exists.
+
+ while (@filter_data = $string_handle->fetchrow_array()){
+
+ $filter_exists = 1;
+
+ }
+
+ # Check if the filter really does exist.
+
+ if (!$filter_exists){
+
+ # The filter does not exist so return
+ # an error value.
+
+ $error = "FilterDoesNotExist";
+ return;
+
+ }
+
+ # Edit the selected filter.
+
+ $string_handle = $database_handle->prepare('UPDATE ' . $class->convert($options{"TablePrefix"}) . '_filters SET
+ findsetting = \'' . $class->convert($filter_newfind) . '\',
+ replacesetting = \'' . $class->convert($filter_newreplace) . '\',
+ priority = \'' . $class->convert($filter_newpriority) . '\',
+ notes = \'' . $class->convert($filter_newnotes) . '\'
+ WHERE id = \'' . $class->convert($filter_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ return;
+
+}
+
+sub deletefilter{
+#################################################################################
+# deletefilter: Deletes a filter from the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->deletefilter(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# FilterID Specifies the filter to delete from the filter database. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my $filter_exists = 0;
+ my @filter_data;
+
+ # Get the values from the hash.
+
+ my $filter_id = $passedoptions->{"FilterID"};
+
+ # Check if the filter exists before deleting.
+
+ $string_handle = $database_handle->prepare('SELECT id FROM ' . $class->convert($options{"TablePrefix"}) . '_filters where id = \'' . $class->convert($filter_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@filter_data = $string_handle->fetchrow_array()){
+
+ $filter_exists = 1;
+
+ }
+
+ # Check to see if the filter really does exist.
+
+ if (!$filter_exists){
+
+ $error = "FilterDoesNotExist";
+ return;
+
+ }
+
+ # Delete the filter from the filter database.
+
+ $string_handle = $database_handle->prepare('DELETE FROM ' . $class->convert($options{"TablePrefix"}) . '_filters where id = \'' . $class->convert($filter_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+1;
\ No newline at end of file
--- /dev/null
+#################################################################################
+# Kiriwrite Database Module - SQLite Database Module (SQLite.pm) #
+# Database module for mainipulating SQLite databases in the database directory. #
+# #
+# Copyright (C) 2007 Steve Brokenshire <sbrokenshire@xestia.co.uk> #
+# #
+# This module is licensed under the same license as Kiriwrite which is the GPL. #
+# #
+# This program is free software; you can redistribute it and/or modify it under #
+# the terms of the GNU General Public License as published by the Free #
+# Software Foundation; as version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.#
+# #
+# You should have received a copy of the GNU General Public License along with #
+# this program; if not, write to the Free Software Foundation, Inc., 51 #
+# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
+#################################################################################
+
+# Define the package (perl module) name.
+
+package Kiriwrite::Database::SQLite;
+
+# Enable strict and use warnings.
+
+use strict;
+use warnings;
+
+# Load the following Perl modules.
+
+use DBI;
+
+# Set the following values.
+
+our $VERSION = "0.1.0";
+my ($options, %options);
+my $database_handle;
+my $string_handle;
+my $second_database_handle;
+my $second_string_handle;
+my $database_filename;
+my $second_database_filename;
+my $templatedb_loaded = 0;
+my $templatedb_exists = 1;
+my $template_string_handle;
+my $template_database_handle;
+my $filterdb_loaded = 0;
+my $filterdb_exists = 1;
+my $filterdb_string_handle;
+my $filterdb_database_handle;
+my $error = "";
+my $errorext = "";
+
+#################################################################################
+# Generic Subroutines. #
+#################################################################################
+
+sub new{
+#################################################################################
+# new: Create an instance of Kiriwrite::Database::SQLite #
+# #
+# Usage: #
+# #
+# $dbmodule = Kiriwrite::Database::SQLite->new(); #
+#################################################################################
+
+ # Get the perl module name.
+
+ my $class = shift;
+ my $self = {};
+
+ return bless($self, $class);
+
+}
+
+sub loadsettings{
+#################################################################################
+# loadsettings: Loads settings into the SQLite database module #
+# #
+# Usage: #
+# #
+# $dbmodule->loadsettings(Directory, options); #
+# #
+# options Specifies the following options (in any order). #
+# #
+# Directory Specifies the directory to use for getting databases. #
+# DateTime Specifies the date and time format to use. #
+# Server Specifies the server to use. #
+# Database Specifies the database to use. #
+# Username Specifies the username to use. #
+# Password Specifies the password to use. #
+# HashType Specifies the password hash type to use. #
+# Port Specifies the server port to use. #
+# Protocol Specifies the protocol to use. #
+# TablePrefix Specifies the table prefix to use. #
+#################################################################################
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ # Add the directory setting to the list of options (as it's the only
+ # one needed for this database module).
+
+ %options = (
+ "Directory" => $passedoptions->{"Directory"},
+ "DateTime" => $passedoptions->{"DateTime"},
+ );
+
+}
+
+sub convert{
+#################################################################################
+# convert: Converts data into SQL formatted data. #
+# #
+# Usage: #
+# #
+# $dbmodule->convert(data); #
+# #
+# data Specifies the data to convert. #
+#################################################################################
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my $data = shift;
+
+ if (!$data){
+ $data = "";
+ }
+
+ $data =~ s/'/''/g;
+ $data =~ s/\b//g;
+
+ return $data;
+
+}
+
+sub dateconvert{
+#################################################################################
+# dateconvert: Converts a SQL date into a proper date. #
+# #
+# Usage: #
+# #
+# $dbmodule->dateconvert(date); #
+# #
+# date Specifies the date to convert. #
+#################################################################################
+
+ # Get the date passed to the subroutine.
+
+ my $class = shift;
+ my $data = shift;
+
+ # Convert the date given into the proper date.
+
+ # Create the following varialbes to be used later.
+
+ my $date;
+ my $time;
+ my $day;
+ my $day_full;
+ my $month;
+ my $month_check;
+ my $month_full;
+ my $year;
+ my $year_short;
+ my $hour;
+ my $hour_full;
+ my $minute;
+ my $minute_full;
+ my $second;
+ my $second_full;
+ my $seek = 0;
+ my $timelength;
+ my $datelength;
+ my $daylength;
+ my $secondlength;
+ my $startchar = 0;
+ my $char;
+ my $length;
+ my $count = 0;
+
+ # Split the date and time.
+
+ $length = length($data);
+
+ if ($length > 0){
+
+ do {
+
+ # Get the character and check if it is a space.
+
+ $char = substr($data, $seek, 1);
+
+ if ($char eq ' '){
+
+ # The character is a space, so get the date and time.
+
+ $date = substr($data, 0, $seek);
+ $timelength = $length - $seek - 1;
+ $time = substr($data, $seek + 1, $timelength);
+
+ }
+
+ $seek++;
+
+ } until ($seek eq $length);
+
+ # Get the year, month and date.
+
+ $length = length($date);
+ $seek = 0;
+
+ do {
+
+ # Get the character and check if it is a dash.
+
+ $char = substr($date, $seek, 1);
+
+ if ($char eq '-'){
+
+ # The character is a dash, so get the year, month or day.
+
+ $datelength = $seek - $startchar;
+
+ if ($count eq 0){
+
+ # Get the year from the date.
+
+ $year = substr($date, 0, $datelength) + 1900;
+ $startchar = $seek;
+ $count = 1;
+
+ # Get the last two characters to get the short year
+ # version.
+
+ $year_short = substr($year, 2, 2);
+
+ } elsif ($count eq 1){
+
+ # Get the month and day from the date.
+
+ $month = substr($date, $startchar + 1, $datelength - 1) + 1;
+
+ # Check if the month is less then 10, if it is
+ # add a zero to the value.
+
+ if ($month < 10){
+
+ $month_full = '0' . $month;
+
+ } else {
+
+ $month_full = $month;
+
+ }
+
+ $startchar = $seek;
+ $count = 2;
+
+ $daylength = $length - $seek + 1;
+ $day = substr($date, $startchar + 1, $daylength);
+
+ # Check if the day is less than 10, if it is
+ # add a zero to the value.
+
+ if ($day < 10){
+
+ $day_full = '0' . $day;
+
+ } else {
+
+ $day_full = $day;
+
+ }
+
+ }
+
+ }
+
+ $seek++;
+
+ } until ($seek eq $length);
+
+ # Get the length of the time value and reset certain
+ # values to 0.
+
+ $length = length($time);
+ $seek = 0;
+ $count = 0;
+ $startchar = 0;
+
+ do {
+
+ # Get the character and check if it is a colon.
+
+ $char = substr($time, $seek, 1);
+
+ if ($char eq ':'){
+
+ # The character is a colon, so get the hour, minute and day.
+
+ $timelength = $seek - $startchar;
+
+ if ($count eq 0){
+
+ # Get the hour from the time.
+
+ $hour = substr($time, 0, $timelength);
+ $count = 1;
+ $startchar = $seek;
+
+ # If the hour is less than ten then add a
+ # zero.
+
+ if ($hour < 10){
+
+ $hour_full = '0' . $hour;
+
+ } else {
+
+ $hour_full = $hour;
+
+ }
+
+ } elsif ($count eq 1){
+
+ # Get the minute and second from the time.
+
+ $minute = substr($time, $startchar + 1, $timelength - 1);
+ $count = 2;
+
+ # If the minute is less than ten then add a
+ # zero.
+
+ if ($minute < 10){
+
+ $minute_full = '0' . $minute;
+
+ } else {
+
+ $minute_full = $minute;
+
+ }
+
+ $startchar = $seek;
+
+ $secondlength = $length - $seek + 1;
+ $second = substr($time, $startchar + 1, $secondlength);
+
+ # If the second is less than ten then add a
+ # zero.
+
+ if ($second < 10){
+
+ $second_full = '0' . $second;
+
+ } else {
+
+ $second_full = $second;
+
+ }
+
+ }
+
+ }
+
+ $seek++;
+
+ } until ($seek eq $length);
+
+ # Get the setting for displaying the date and time.
+
+ $data = $options{"DateTime"};
+
+ # Process the setting for displaying the date and time
+ # using regular expressions
+
+ $data =~ s/DD/$day_full/g;
+ $data =~ s/D/$day/g;
+ $data =~ s/MM/$month_full/g;
+ $data =~ s/M/$month/g;
+ $data =~ s/YY/$year/g;
+ $data =~ s/Y/$year_short/g;
+
+ $data =~ s/hh/$hour_full/g;
+ $data =~ s/h/$hour/g;
+ $data =~ s/mm/$minute_full/g;
+ $data =~ s/m/$minute/g;
+ $data =~ s/ss/$second_full/g;
+ $data =~ s/s/$second/g;
+
+ }
+
+ return $data;
+
+}
+
+sub geterror{
+#################################################################################
+# geterror: Gets the error message (or extended error message). #
+# #
+# Usage: #
+# #
+# $dbmodule->geterror(extended); #
+# #
+# Extended Specifies if the extended error should be retrieved. #
+#################################################################################
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my $extended = shift;
+
+ if (!$extended){
+ $extended = 0;
+ }
+
+ if (!$errorext){
+ $errorext = "";
+ }
+
+ if (!$error){
+ $error = "";
+ }
+
+ # Check to see if extended information should be returned.
+
+ if ($extended eq 1){
+
+ # Extended information should be returned.
+
+ return $errorext;
+
+ } else {
+
+ # Basic information should be returned.
+
+ return $error;
+
+ }
+
+}
+
+sub dbpermissions{
+#################################################################################
+# dbpermissions: Check if the permissions for the database are valid. #
+# #
+# Usage: #
+# #
+# $database->dbpermissions(dbname, read, write); #
+# #
+# dbname Specifies the database name to check. #
+# read Check to see if the database can be read. #
+# write Check to see if the database can be written. #
+#################################################################################
+
+ # Get the database name, read setting and write setting.
+
+ my ($class, $dbname, $readper, $writeper) = @_;
+
+ # Check if the database can be read.
+
+ if ($readper){
+
+ if (-r $options{"Directory"} . '/' . $dbname . ".db.sqlite"){
+
+ # The database can be read.
+
+ } else {
+
+ # The database cannot be read, so return a value
+ # of 1.
+
+ return 1;
+
+ }
+
+ }
+
+ # Check if the database can be written.
+
+ if ($writeper){
+
+ if (-w $options{"Directory"} . '/' . $dbname . ".db.sqlite"){
+
+ # The database can be read.
+
+ } else {
+
+ # The database cannot be read, so return a value
+ # of 1.
+
+ return 1;
+
+ }
+
+ }
+
+ # No errors have occured while checking so return a value
+ # of 0.
+
+ return 0;
+
+}
+
+sub dbexists{
+#################################################################################
+# dbexists: Check if the database exists. #
+# #
+# Usage: #
+# #
+# $dbmodule->dbexists(dbname); #
+# #
+# dbname Specifies the database name to check. #
+#################################################################################
+
+ # Get the value that was passed to the subroutine.
+
+ my $class = shift;
+ my ($filename) = @_;
+
+ # Check if the filename exists, if it does, return a value of 1, else
+ # return a value of 0, meaning that the file was not found.
+
+ if (-e $options{"Directory"} . '/' . $filename . ".db.sqlite"){
+
+ # Specified file does exist so return a value of 0.
+
+ return 0;
+
+ } else {
+
+ # Specified file does not exist so return a value of 1.
+
+ return 1;
+
+ }
+
+}
+
+#################################################################################
+# Database Subroutines. #
+#################################################################################
+
+sub getdblist{
+#################################################################################
+# getdblist: Gets the list of available databases. #
+# #
+# Usage: #
+# #
+# $dbmodule->getdblist(); #
+#################################################################################
+
+ # Get the list of databases.
+
+ my @data_directory;
+ my @data_directory_final;
+ my $database;
+ my $database_filename_length;
+ my $database_filename_friendly;
+
+ # Check if the database directory has valid permission settings.
+
+ if (-e $options{"Directory"}){
+
+ # The database directory does exist. So check if
+ # the permission settings are valid.
+
+ if (-r $options{"Directory"}){
+
+ # The permission settings for reading the directory
+ # are valid.
+
+ } else {
+
+ # The permission settings for reading the directory
+ # are invalid so return an error value.
+
+ $error = "DataDirInvalidPermissions";
+ return;
+
+ }
+
+ } else {
+
+ # The database directory does not exist, so return an
+ # error value.
+
+ $error = "DataDirMissing";
+ return;
+
+ }
+
+ opendir(DATADIR, $options{"Directory"});
+ @data_directory = grep /m*\.db.sqlite$/, readdir(DATADIR);
+ closedir(DATADIR);
+
+ # Process the list of databases.
+
+ foreach $database (@data_directory){
+
+ $database =~ s/.db.sqlite$//g;
+ $database_filename_friendly = $database;
+
+ #$database_filename_length = length($database);
+ #$database_filename_friendly = substr($database, 0, $database_filename_length - 3);
+ push(@data_directory_final, $database_filename_friendly);
+
+ }
+
+ # Return the list of databases.
+
+ return @data_directory_final;
+
+}
+
+sub getdatabaseinfo{
+#################################################################################
+# getdatabaseinfo: Get information about the database. #
+# #
+# Usage: #
+# #
+# $dbmodule->getdatabaseinfo(); #
+#################################################################################
+
+ # Get the database information.
+
+ my $class = shift;
+ my ($databaseinfo, %databaseinfo);
+ my ($sqldata, @sqldata);
+
+ $error = "";
+ $errorext = "";
+
+ $string_handle = $database_handle->prepare('SELECT name, description, notes, categories, kiriwrite_version_major, kiriwrite_version_minor, kiriwrite_version_revision FROM kiriwrite_database_info LIMIT 1') or (
+ $error = "DatabaseError", $errorext = $database_handle->errstr, return
+ );
+ $string_handle->execute();
+
+ @sqldata = $string_handle->fetchrow_array();
+
+ # Process the database information into a hash.
+
+ %databaseinfo = (
+ "DatabaseName" => $sqldata[0],
+ "Description" => $sqldata[1],
+ "Notes" => $sqldata[2],
+ "Categories" => $sqldata[3],
+ "Major" => $sqldata[4],
+ "Minor" => $sqldata[5],
+ "Revision" => $sqldata[6]
+ );
+
+ $string_handle->finish();
+ undef $string_handle;
+
+ return %databaseinfo;
+
+}
+
+sub getseconddatabaseinfo{
+#################################################################################
+# getseconddatabaseinfo: Get information about the database that pages will be #
+# moved or copied to. #
+# #
+# Usage: #
+# #
+# $dbmodule->getseconddatabaseinfo(); #
+#################################################################################
+
+ # Get the database information.
+
+ my $class = shift;
+ my ($databaseinfo, %databaseinfo);
+ my ($sqldata, @sqldata);
+
+ $error = "";
+ $errorext = "";
+
+ $second_string_handle = $second_database_handle->prepare('SELECT name, description, notes, categories, kiriwrite_version_major, kiriwrite_version_minor, kiriwrite_version_revision FROM kiriwrite_database_info LIMIT 1') or (
+ $error = "DatabaseError", $errorext = $second_database_handle->errstr, return
+ );
+ $second_string_handle->execute();
+
+ @sqldata = $second_string_handle->fetchrow_array();
+
+ # Process the database information into a hash.
+
+ %databaseinfo = (
+ "DatabaseName" => $sqldata[0],
+ "Description" => $sqldata[1],
+ "Notes" => $sqldata[2],
+ "Categories" => $sqldata[3],
+ "Major" => $sqldata[4],
+ "Minor" => $sqldata[5],
+ "Revision" => $sqldata[6]
+ );
+
+ $second_string_handle->finish();
+ undef $second_string_handle;
+
+ return %databaseinfo;
+
+}
+
+sub adddatabase{
+#################################################################################
+# adddatabase: Adds a Kiriwrite database. #
+# #
+# Usage: #
+# #
+# $dbmodule->adddatabase(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# DatabaseFilename Specifies the database file/shortname to use. #
+# DatabaseName Specifies the database name to use. #
+# DatabaseDescription Specifies the database description to use. #
+# DatabaseNotes Specifies the database notes to use. #
+# DatabaseCategories Specifies the database categories to use. #
+# VersionMajor Specifies the major version. #
+# VersionMinor Specifies the minor version. #
+# VersionRevision Specifies the revision version. #
+#################################################################################
+
+ # Get the database that was passed to the subroutine.
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my $dbfilename = $passedoptions->{"DatabaseFilename"};
+ my $dbname = $passedoptions->{"DatabaseName"};
+ my $dbdescription = $passedoptions->{"DatabaseDescription"};
+ my $dbnotes = $passedoptions->{"DatabaseNotes"};
+ my $dbcategories = $passedoptions->{"DatabaseCategories"};
+ my $dbmajorver = $passedoptions->{"VersionMajor"};
+ my $dbminorver = $passedoptions->{"VersionMinor"};
+ my $dbrevisionver = $passedoptions->{"VersionRevision"};
+
+ # Check if the database with the filename given already exists.
+
+ my $database_exists = $class->dbexists($dbfilename);
+
+ if ($database_exists eq 0){
+
+ # The database filename exists so set the error value.
+
+ $error = "DatabaseExists";
+ return;
+
+ }
+
+ # Create the database structure.
+
+ $database_handle = DBI->connect("dbi:SQLite:dbname=" . $options{"Directory"} . '/' . $dbfilename . ".db.sqlite");
+ $database_handle->{unicode} = 1;
+ $string_handle = $database_handle->prepare('CREATE TABLE kiriwrite_database_info(
+ name varchar(256) primary key,
+ description varchar(512),
+ notes text,
+ categories varchar(512),
+ kiriwrite_version_major int(4),
+ kiriwrite_version_minor int(4),
+ kiriwrite_version_revision int(4)
+ )') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ $string_handle = $database_handle->prepare('CREATE TABLE kiriwrite_database_pages(
+ filename varchar(256) primary key,
+ pagename varchar(512),
+ pagedescription varchar(512),
+ pagesection varchar(256),
+ pagetemplate varchar(64),
+ pagedata text,
+ pagesettings int(1),
+ lastmodified datetime
+ )') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Convert the values into SQL query formatted values and add an entry
+ # to the kiriwrite_database_info table.
+
+ $string_handle = $database_handle->prepare('INSERT INTO kiriwrite_database_info (name, description, notes, categories, kiriwrite_version_major, kiriwrite_version_minor, kiriwrite_version_revision) VALUES(
+ \'' . $class->convert($dbname) . '\',
+ \'' . $class->convert($dbdescription) . '\',
+ \'' . $class->convert($dbnotes) . '\',
+ \'' . $class->convert($dbcategories) . '\',
+ \'' . $class->convert($dbmajorver) . '\',
+ \'' . $class->convert($dbminorver) . '\',
+ \'' . $class->convert($dbrevisionver) . '\'
+ )') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub editdatabase{
+#################################################################################
+# editdatabase: Edits a Kiriwrite Database. #
+# #
+# Usage: #
+# #
+# $dbmodule->editdatabase(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# NewDatabaseFilename Specifies the new database filename to use. #
+# DatabaseName Specifies the new database name. #
+# DatabaseDescription Specifies the new database description. #
+# DatabaseNotes Specifies the new database notes. #
+# DatabaseCategories Specifies the new database categories. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my $dbnewfilename = $passedoptions->{"DatabaseNewFilename"};
+ my $dbname = $passedoptions->{"DatabaseName"};
+ my $dbdescription = $passedoptions->{"DatabaseDescription"};
+ my $dbnotes = $passedoptions->{"DatabaseNotes"};
+ my $dbcategories = $passedoptions->{"DatabaseCategories"};
+
+ # Check if a new database filename has been specified and if a
+ # new database filename has been specified then change the
+ # database filename.
+
+ if ($database_filename ne $dbnewfilename){
+
+ # A new database filename has been given so check if the output
+ # directory has write access.
+
+ if (-r $options{"Directory"}){
+
+ # The directory is readable.
+
+ } else {
+
+ # The directory is not readable so set the error value.
+
+ $error = "DataDirInvalidPermissions";
+
+ return;
+
+ }
+
+ if (-w $options{"Directory"}){
+
+ # The directory is writeable.
+
+ } else {
+
+ # The directory is not writeable so set the error value.
+
+ $error = "DataDirInvalidPermissions";
+
+ return;
+
+ }
+
+ # Check if a database filename already exists before using the
+ # new filename.
+
+ my $database_newexists = $class->dbexists($dbnewfilename);
+
+ if ($database_newexists eq 0){
+
+ # The database filename exists so set the error value.
+
+ $error = "DatabaseExists";
+ return;
+
+ }
+
+ # Check if the database can be renamed (has write access).
+
+ my $database_permissions = $class->dbpermissions($database_filename, 1, 1);
+
+ if ($database_permissions eq 1){
+
+ # The database filename exists so set the error value.
+
+ $error = "InvalidPermissionsSet";
+ return;
+
+ }
+
+ # "Disconnect" from the database.
+
+ $database_handle->disconnect();
+
+ # Rename the database.
+
+ ($database_filename) = $database_filename =~ /^([a-zA-Z0-9.]+)$/;
+ ($dbnewfilename) = $dbnewfilename =~ /^([a-zA-Z0-9.]+)$/;
+
+ rename($options{"Directory"} . '/' . $database_filename . '.db.sqlite', $options{"Directory"} . '/' . $dbnewfilename . '.db.sqlite');
+
+ # Reload the database from the new filename.
+
+ $database_handle = DBI->connect("dbi:SQLite:dbname=" . $options{"Directory"} . '/' . $dbnewfilename . ".db.sqlite");
+ $database_handle->{unicode} = 1;
+ $database_filename = $dbnewfilename;
+
+ }
+
+ # Check if the database can be altered with the new data.
+
+ my $database_permissions = $class->dbpermissions($database_filename, 1, 1);
+
+ if ($database_permissions eq 1){
+
+ # The database filename exists so set the error value.
+
+ $error = "InvalidPermissionsSet";
+ return;
+
+ }
+
+ # Get the current database information.
+
+ $string_handle = $database_handle->prepare('SELECT name FROM kiriwrite_database_info LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ my @database_oldinfo = $string_handle->fetchrow_array();
+
+ my $dboldname = $database_oldinfo[0];
+
+ # Update the database information.
+
+ $string_handle = $database_handle->prepare('UPDATE kiriwrite_database_info SET name = \'' . $class->convert($dbname) . '\',
+ description = \'' . $class->convert($dbdescription) . '\',
+ notes = \'' . $class->convert($dbnotes) . '\',
+ categories = \'' . $class->convert($dbcategories) . '\'') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ undef $string_handle;
+ return;
+
+}
+
+sub deletedatabase{
+#################################################################################
+# deletedatabase: Deletes a Kiriwrite database. #
+# #
+# Usage: #
+# #
+# $dbmodule->deletedatabase(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# DatabaseName Specifies the Kiriwrite database to delete. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the database filename.
+
+ my $class = shift;
+ my ($passedoptions) = shift;
+
+ my $databasename = $passedoptions->{"DatabaseName"};
+
+ # Check if the database exists.
+
+ my $database_exists = $class->dbexists($databasename);
+
+ if ($database_exists eq 1){
+
+ # The database does not exist so set the error value.
+
+ $error = "DoesNotExist";
+ return;
+
+ }
+
+ # Check if the database permissions are valid.
+
+ my $database_permissions = $class->dbpermissions($databasename);
+
+ if ($database_permissions eq 1){
+
+ # The database permissions are invalid so set the error
+ # value.
+
+ $error = "InvalidPermissionsSet";
+ return;
+
+ }
+
+ # Delete the database.
+
+ ($databasename) = $databasename =~ /^([a-zA-Z0-9.]+)$/;
+
+ unlink($options{"Directory"} . '/' . $databasename . '.db.sqlite');
+
+}
+
+sub selectdb{
+#################################################################################
+# selectdb: Selects the Kiriwrite database. #
+# #
+# Usage: #
+# #
+# $dbmodule->connect(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# DatabaseName Specifies the Kiriwrite database to use. #
+#################################################################################
+
+ # Get the database name.
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+ my (%database, $database);
+
+ my $dbname = $passedoptions->{"DatabaseName"};
+
+ # Check if the database exists.
+
+ my $database_exists = $class->dbexists($dbname);
+
+ if ($database_exists eq 1){
+
+ # The database does not exist so return an error value
+ # saying that the database does not exist.
+
+ $error = "DoesNotExist";
+
+ return;
+
+ }
+
+ # Check if the database has valid permissions set.
+
+ my $database_permissions = $class->dbpermissions($dbname, 1, 0);
+
+ if ($database_permissions eq 1){
+
+ # The database has invalid permissions set so return
+ # an error value saying that the database has invalid
+ # permissions set.
+
+ $error = "InvalidPermissionsSet";
+
+ return;
+
+ }
+
+ # Connect to the database.
+
+ $database_handle = DBI->connect("dbi:SQLite:dbname=" . $options{"Directory"} . '/' . $dbname . ".db.sqlite");
+ $database_handle->{unicode} = 1;
+ $database_filename = $dbname;
+
+}
+
+sub selectseconddb{
+#################################################################################
+# selectseconddb: Selects a second Kiriwrite database for moving and copying #
+# pages to. #
+# #
+# Usage: #
+# #
+# $dbmodule->selectseconddb(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# DatabaseName Specifies the Kiriwrite database to use. #
+#################################################################################
+
+ # Get the database name.
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+ my (%database, $database);
+
+ my $dbname = $passedoptions->{"DatabaseName"};
+
+ # Check if the database exists.
+
+ my $database_exists = $class->dbexists($dbname);
+
+ if ($database_exists eq 1){
+
+ # The database does not exist so return an error value
+ # saying that the database does not exist.
+
+ $error = "DoesNotExist";
+
+ return;
+
+ }
+
+ # Check if the database has valid permissions set.
+
+ my $database_permissions = $class->dbpermissions($dbname, 1, 0);
+
+ if ($database_permissions eq 1){
+
+ # The database has invalid permissions set so return
+ # an error value saying that the database has invalid
+ # permissions set.
+
+ $error = "InvalidPermissionsSet";
+
+ return;
+
+ }
+
+ # Connect to the database.
+
+ $second_database_handle = DBI->connect("dbi:SQLite:dbname=" . $options{"Directory"} . '/' . $dbname . ".db.sqlite");
+ $second_database_handle->{unicode} = 1;
+ $second_database_filename = $dbname;
+
+}
+
+#################################################################################
+# Page subroutines. #
+#################################################################################
+
+sub getpagelist{
+#################################################################################
+# getpagelist: Gets the list of pages from the database. #
+# #
+# Usage: #
+# #
+# $dbmodule->getpagelist(); #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM kiriwrite_database_pages') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ my @database_pagefilenames;
+ my @database_pagefilenames_final;
+
+ # Process the collected pages.
+
+ while (@database_pagefilenames = $string_handle->fetchrow_array){
+
+ # Add each page to the list of pages in the database.
+
+ push(@database_pagefilenames_final, $database_pagefilenames[0]);
+
+ }
+
+ undef $string_handle;
+ return @database_pagefilenames_final;
+
+}
+
+sub getpageinfo{
+#################################################################################
+# getpageinfo: Gets the page information from the filename passed. #
+# #
+# Usage: #
+# #
+# $dbmodule->getpageinfo(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the page filename to get the page information from. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = shift;
+ my (%database_page, $database_page);
+ my ($pagefilename, $pagename, $pagedescription, $pagesection, $pagetemplate, $pagedata, $pagesettings, $pagelastmodified);
+
+ my @data_page;
+ my $page_found = 0;
+
+ # Get the page from the database.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+
+ $string_handle = $database_handle->prepare('SELECT filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if the page exists in the database.
+
+ while (@data_page = $string_handle->fetchrow_array()){
+
+ # Get the values from the array.
+
+ $pagefilename = $data_page[0];
+ $pagename = $data_page[1];
+ $pagedescription = $data_page[2];
+ $pagesection = $data_page[3];
+ $pagetemplate = $data_page[4];
+ $pagedata = $data_page[5];
+ $pagesettings = $data_page[6];
+ $pagelastmodified = $data_page[7];
+
+ # Put the values into the page hash.
+
+ %database_page = (
+ "PageFilename" => $pagefilename,
+ "PageName" => $pagename,
+ "PageDescription" => $pagedescription,
+ "PageSection" => $pagesection,
+ "PageTemplate" => $pagetemplate,
+ "PageContent" => $pagedata,
+ "PageSettings" => $pagesettings,
+ "PageLastModified" => $class->dateconvert($pagelastmodified),
+ );
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page did exist.
+
+ if (!$page_found){
+
+ $error = "PageDoesNotExist";
+ return;
+
+ }
+
+ undef $string_handle;
+ return %database_page;
+
+}
+
+sub addpage{
+#################################################################################
+# addpage: Add a page to the selected database. #
+# #
+# Usage: #
+# #
+# $dbmodule->addpage(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the page filename to use. #
+# PageName Specifies the page name to use. #
+# PageDescription Specifies the page description to use. #
+# PageSection Specifies the page section to use. #
+# PageTemplate Specifies the page template to use. #
+# PageContent Specifies the page content to use. #
+# PageSettings Specifies the page settings to use. #
+#################################################################################
+
+ # Get the data that was passed to the subroutine.
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my ($passedoptions) = shift;
+
+ my @database_page;
+ my $page_count = 0;
+
+ # Get the values passed to the hash.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+ my $page_name = $passedoptions->{"PageName"};
+ my $page_description = $passedoptions->{"PageDescription"};
+ my $page_section = $passedoptions->{"PageSection"};
+ my $page_template = $passedoptions->{"PageTemplate"};
+ my $page_content = $passedoptions->{"PageContent"};
+ my $page_settings = $passedoptions->{"PageSettings"};
+
+ # Check to see if the filename given already exists
+ # in the page database.
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if a page with the filename given really does
+ # exist.
+
+ while (@database_page = $string_handle->fetchrow_array()){
+
+ # A page does exist so increment the count to 1.
+
+ $page_count++;
+
+ }
+
+ if ($page_count ne 0){
+
+ # The page does exist so set the error value.
+
+ $error = "PageExists";
+ return;
+
+ }
+
+ # Check if certain values are undefined.
+
+ if (!$page_name){
+
+ $page_name = "";
+
+ }
+
+ if (!$page_description){
+
+ $page_description = "";
+
+ }
+
+ if (!$page_section){
+
+ $page_section = "";
+
+ }
+
+ if (!$page_content){
+
+ $page_content = "";
+
+ }
+
+ my ($created_second, $created_minute, $created_hour, $created_day, $created_month, $created_year, $created_weekday, $created_yearday, $created_dst) = localtime;
+ my $page_date = $created_year . '-' . $created_month . '-' . $created_day . ' ' . $created_hour . ':' . $created_minute . ':' . $created_second;
+
+ # Add the page to the selected database.
+
+ $string_handle = $database_handle->prepare('INSERT INTO kiriwrite_database_pages (filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified) VALUES (
+ \'' . $class->convert($page_filename) . '\',
+ \'' . $class->convert($page_name) . '\',
+ \'' . $class->convert($page_description) . '\',
+ \'' . $class->convert($page_section) . '\',
+ \'' . $class->convert($page_template) . '\',
+ \'' . $class->convert($page_content) . '\',
+ \'' . $class->convert($page_settings) . '\',
+ \'' . $class->convert($page_date) . '\'
+ )') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ undef $string_handle;
+
+}
+
+sub deletepage{
+#################################################################################
+# deletepage: Delete a page from the selected database. #
+# #
+# Usage: #
+# #
+# $dbmodule->deletepage(options) #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the page filename to delete. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the data that was passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+ my @page_info;
+ my $page_found = 0;
+
+ # Get the page filename.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+
+ # Check if the page exists before deleting it.
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ while (@page_info = $string_handle->fetchrow_array()){
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if (!$page_found){
+
+ $error = "PageDoesNotExist";
+ return;
+
+ }
+
+ # Delete the page.
+
+ $string_handle = $database_handle->prepare('DELETE FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\'') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub editpage{
+#################################################################################
+# editpage: Edit a page from the selected database. #
+# #
+# Usage: #
+# #
+# $dbmodule->editpage(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the filename to edit. #
+# PageNewFilename Specifies the new filename to use. #
+# PageNewName Specifies the new page name to use. #
+# PageNewDescription Specifies the new page description to use. #
+# PageNewSection Specifies the new page section to use. #
+# PageNewTemplate Specifies the new page template to use. #
+# PageNewContent Specifies the new page content to use. #
+# PageNewSettings Specifies the new page settings to use. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+ my $page_found = 0;
+ my @page_info;
+
+ # Get the data that was passed to the subroutine.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+ my $page_newfilename = $passedoptions->{"PageNewFilename"};
+ my $page_newname = $passedoptions->{"PageNewName"};
+ my $page_newdescription = $passedoptions->{"PageNewDescription"};
+ my $page_newsection = $passedoptions->{"PageNewSection"};
+ my $page_newtemplate = $passedoptions->{"PageNewTemplate"};
+ my $page_newcontent = $passedoptions->{"PageNewContent"};
+ my $page_newsettings = $passedoptions->{"PageNewSettings"};
+
+ # Check if the page with the filename given exists.
+
+ $string_handle = $database_handle->prepare('SELECT filename FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if the page really does exist.
+
+ while (@page_info = $string_handle->fetchrow_array()){
+
+ # The page information is found.
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if (!$page_found){
+
+ $error = "PageDoesNotExist";
+ return;
+
+ }
+
+ # Get the current date.
+
+ my ($created_second, $created_minute, $created_hour, $created_day, $created_month, $created_year, $created_weekday, $created_yearday, $created_dst) = localtime;
+ my $page_date = $created_year . '-' . $created_month . '-' . $created_day . ' ' . $created_hour . ':' . $created_minute . ':' . $created_second;
+
+ # Edit the selected page.
+
+ $string_handle = $database_handle->prepare('UPDATE kiriwrite_database_pages SET filename = \'' . $class->convert($page_newfilename) . '\', pagename = \'' . $class->convert($page_newname) . '\', pagedescription = \'' . $class->convert($page_newdescription) . '\', pagesection = \'' . $class->convert($page_newsection) . '\', pagetemplate = \'' . $class->convert($page_newtemplate) . '\', pagedata = \'' . $class->convert($page_newcontent) . '\', pagedata = \'' . $class->convert($page_newcontent) . '\', pagesettings = \'' . $class->convert($page_newsettings) . '\', lastmodified = \'' . $page_date . '\' WHERE filename = \'' . $class->convert($page_filename) . '\'') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub movepage{
+#################################################################################
+# movepage: Moves a page from the old database to the new database. #
+# #
+# Usage: #
+# #
+# $dbmodule->movepage(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the page with the filename to move. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my (%database_page, $database_page);
+ my ($pagefilename, $pagename, $pagedescription, $pagesection, $pagetemplate, $pagedata, $pagesettings, $pagelastmodified);
+ my @page_info;
+ my $page_found = 0;
+
+ # Get the data that was passed to the subroutine.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+
+ # Check if the page with the filename given exists.
+
+ $string_handle = $database_handle->prepare('SELECT filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "OldDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if the page really does exist.
+
+ while (@page_info = $string_handle->fetchrow_array()){
+
+ # Get the values from the array.
+
+ $pagefilename = $page_info[0];
+ $pagename = $page_info[1];
+ $pagedescription = $page_info[2];
+ $pagesection = $page_info[3];
+ $pagetemplate = $page_info[4];
+ $pagedata = $page_info[5];
+ $pagesettings = $page_info[6];
+ $pagelastmodified = $page_info[7];
+
+ # Put the values into the page hash.
+
+ %database_page = (
+ "PageFilename" => $pagefilename,
+ "PageName" => $pagename,
+ "PageDescription" => $pagedescription,
+ "PageSection" => $pagesection,
+ "PageTemplate" => $pagetemplate,
+ "PageContent" => $pagedata,
+ "PageSettings" => $pagesettings,
+ "PageLastModified" => $pagelastmodified,
+ );
+
+ # The page information is found.
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if (!$page_found){
+
+ $error = "PageDoesNotExist";
+ return;
+
+ }
+
+ # Check if the page with the filename given already exists in
+ # the database the page is being moved to.
+
+ $page_found = 0;
+ @page_info = ();
+
+ $second_string_handle = $second_database_handle->prepare('SELECT filename FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "NewDatabaseError", $errorext = $second_database_handle->errstr, return );
+ $second_string_handle->execute();
+
+ while (@page_info = $second_string_handle->fetchrow_array()){
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if ($page_found){
+
+ $error = "PageAlreadyExists";
+ return;
+
+ }
+
+ # Add the page to the new database.
+
+ $second_string_handle = $second_database_handle->prepare('INSERT INTO kiriwrite_database_pages (filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified) VALUES (
+ \'' . $class->convert($database_page{"PageFilename"}) . '\',
+ \'' . $class->convert($database_page{"PageName"}) . '\',
+ \'' . $class->convert($database_page{"PageDescription"}) . '\',
+ \'' . $class->convert($database_page{"PageSection"}) . '\',
+ \'' . $class->convert($database_page{"PageTemplate"}) . '\',
+ \'' . $class->convert($database_page{"PageContent"}) . '\',
+ \'' . $class->convert($database_page{"PageSettings"}) . '\',
+ \'' . $class->convert($database_page{"PageLastModified"}) . '\'
+ )') or ( $error = "NewDatabaseError", $errorext = $second_database_handle->errstr, return );
+ $second_string_handle->execute();
+
+ # Delete the page from the old database.
+
+ $string_handle = $database_handle->prepare('DELETE FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($database_page{"PageFilename"}) . '\'') or ( $error = "OldDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+}
+
+sub copypage{
+#################################################################################
+# copypage: Copies a page from the old database to the new database. #
+# #
+# Usage: #
+# #
+# $dbmodule->copypage(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# PageFilename Specifies the page with the filename to copy. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my (%database_page, $database_page);
+ my ($pagefilename, $pagename, $pagedescription, $pagesection, $pagetemplate, $pagedata, $pagesettings, $pagelastmodified);
+ my @page_info;
+ my $page_found = 0;
+
+ # Get the data that was passed to the subroutine.
+
+ my $page_filename = $passedoptions->{"PageFilename"};
+
+ # Check if the page with the filename given exists.
+
+ $string_handle = $database_handle->prepare('SELECT filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "OldDatabaseError", $errorext = $database_handle->errstr, return );
+ $string_handle->execute();
+
+ # Check if the page really does exist.
+
+ while (@page_info = $string_handle->fetchrow_array()){
+
+ # Get the values from the array.
+
+ $pagefilename = $page_info[0];
+ $pagename = $page_info[1];
+ $pagedescription = $page_info[2];
+ $pagesection = $page_info[3];
+ $pagetemplate = $page_info[4];
+ $pagedata = $page_info[5];
+ $pagesettings = $page_info[6];
+ $pagelastmodified = $page_info[7];
+
+ # Put the values into the page hash.
+
+ %database_page = (
+ "PageFilename" => $pagefilename,
+ "PageName" => $pagename,
+ "PageDescription" => $pagedescription,
+ "PageSection" => $pagesection,
+ "PageTemplate" => $pagetemplate,
+ "PageContent" => $pagedata,
+ "PageSettings" => $pagesettings,
+ "PageLastModified" => $pagelastmodified,
+ );
+
+ # The page information is found.
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if (!$page_found){
+
+ $error = "PageDoesNotExist";
+ return;
+
+ }
+
+ # Check if the page with the filename given already exists in
+ # the database the page is being moved to.
+
+ $page_found = 0;
+ @page_info = ();
+
+ $second_string_handle = $second_database_handle->prepare('SELECT filename FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($page_filename) . '\' LIMIT 1') or ( $error = "NewDatabaseError", $errorext = $second_database_handle->errstr, return );
+ $second_string_handle->execute();
+
+ while (@page_info = $second_string_handle->fetchrow_array()){
+
+ $page_found = 1;
+
+ }
+
+ # Check if the page really does exist.
+
+ if ($page_found){
+
+ $error = "PageAlreadyExists";
+ return;
+
+ }
+
+ # Add the page to the new database.
+
+ $second_string_handle = $second_database_handle->prepare('INSERT INTO kiriwrite_database_pages (filename, pagename, pagedescription, pagesection, pagetemplate, pagedata, pagesettings, lastmodified) VALUES (
+ \'' . $class->convert($database_page{"PageFilename"}) . '\',
+ \'' . $class->convert($database_page{"PageName"}) . '\',
+ \'' . $class->convert($database_page{"PageDescription"}) . '\',
+ \'' . $class->convert($database_page{"PageSection"}) . '\',
+ \'' . $class->convert($database_page{"PageTemplate"}) . '\',
+ \'' . $class->convert($database_page{"PageContent"}) . '\',
+ \'' . $class->convert($database_page{"PageSettings"}) . '\',
+ \'' . $class->convert($database_page{"PageLastModified"}) . '\'
+ )') or ( $error = "NewDatabaseError", $errorext = $second_database_handle->errstr, return );
+ $second_string_handle->execute();
+
+}
+
+#################################################################################
+# Filter subroutines. #
+#################################################################################
+
+sub connectfilter{
+#################################################################################
+# connectfilter: Connect to the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->connectfilter(missingignore); #
+# #
+# missingignore Ignore error about database being missing. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my $ignoremissing = shift;
+
+ # Check if the template database exists.
+
+ my $filterdatabase_exists = main::kiriwrite_fileexists("filters.db.sqlite");
+
+ if ($filterdatabase_exists eq 1){
+
+ $filterdb_exists = 0;
+
+ if (!$ignoremissing){
+
+ $error = "FilterDatabaseDoesNotExist";
+ return;
+
+ }
+
+ }
+
+ # Check if the permission settings for the template database are valid.
+
+ my $filterdb_permissions = main::kiriwrite_filepermissions("filters.db.sqlite", 1, 0);
+
+ if ($filterdb_permissions eq 1){
+
+ # The template database has invalid permissions set
+ # so return an error value.
+
+ if (!$ignoremissing){
+
+ $error = "FilterDatabaseInvalidPermissionsSet";
+ return;
+
+ }
+
+ }
+
+ # Connect to the template database.
+
+ $filterdb_database_handle = DBI->connect("dbi:SQLite:dbname=filters.db.sqlite");
+ $database_handle->{unicode} = 1;
+ $filterdb_loaded = 1;
+
+}
+
+sub disconnectfilter{
+#################################################################################
+# disconnectfilter: Disconnect from the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->disconnectfilter(); #
+#################################################################################
+
+ # Disconnect the template database.
+
+ if ($filterdb_loaded eq 1){
+
+ undef $filterdb_string_handle;
+ $filterdb_database_handle->disconnect();
+
+ }
+
+}
+
+sub getfilterlist{
+#################################################################################
+# getfilterlist: Gets the list of filters in the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->getfilterlist(); #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my @filter_list;
+ my @filter_data;
+
+ # Get the list of filters available.
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('SELECT id FROM kiriwrite_filters ORDER BY priority ASC') or ( $error = "FilterDatabaseError", $errorext = $filterdb_database_handle->errstr, return );
+ $filterdb_string_handle->execute();
+
+ while (@filter_data = $filterdb_string_handle->fetchrow_array()){
+
+ # Add the filter to the list of available filters.
+
+ push(@filter_list, $filter_data[0]);
+
+ }
+
+ undef $filterdb_string_handle;
+ return @filter_list;
+
+}
+
+sub getfilterinfo{
+#################################################################################
+# getfilterinfo: Gets information about the filter. #
+# #
+# Usage: #
+# #
+# $dbmodule->getfilterinfo(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# FilterID Specifies the filter ID number to get information from. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my %filter_info;
+ my $filter_exists = 0;
+ my @filter_data;
+
+ # Get the values that are in the hash.
+
+ my $filter_id = $passedoptions->{"FilterID"};
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('SELECT id, priority, findsetting, replacesetting, notes FROM kiriwrite_filters where id = \'' . $class->convert($filter_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $filterdb_database_handle->errstr, return );
+ $filterdb_string_handle->execute();
+
+ # Get the filter information.
+
+ while (@filter_data = $filterdb_string_handle->fetchrow_array()){
+
+ $filter_info{"FilterID"} = $filter_data[0];
+ $filter_info{"FilterPriority"} = $filter_data[1];
+ $filter_info{"FilterFind"} = $filter_data[2];
+ $filter_info{"FilterReplace"} = $filter_data[3];
+ $filter_info{"FilterNotes"} = $filter_data[4];
+
+ $filter_exists = 1;
+
+ }
+
+ # Check if the filter exists.
+
+ if (!$filter_exists){
+
+ # The filter does not exist so return
+ # an error value.
+
+ $error = "FilterDoesNotExist";
+ return;
+
+ }
+
+ # Return the filter information.
+
+ undef $filterdb_string_handle;
+ return %filter_info;
+
+}
+
+sub addfilter{
+#################################################################################
+# addfilter: Adds a filter to the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->addfilter(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# FindFilter Specifies the find filter to add. #
+# ReplaceFilter Specifies the replace filter to add. #
+# Priority Specifies the filter priority to use. #
+# Notes Specifies the notes to use. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ # Define some variables for later.
+
+ my @database_filters;
+ my @filterid_list;
+ my @filterid_check;
+ my $nofiltertable = 0;
+ my $filter_found = 0;
+ my $filter_count = 0;
+ my $filter_id;
+ my $new_id;
+
+ # Get the values from the hash.
+
+ my $filter_find = $passedoptions->{"FindFilter"};
+ my $filter_replace = $passedoptions->{"ReplaceFilter"};
+ my $filter_priority = $passedoptions->{"Priority"};
+ my $filter_notes = $passedoptions->{"Notes"};
+
+ # Check if the filter database permissions are valid.
+
+ my $filterdb_exists = main::kiriwrite_fileexists("filters.db.sqlite", 1, 1);
+ my $filterdb_permissions = main::kiriwrite_filepermissions("filters.db.sqlite", 1, 1);
+
+ if ($filterdb_permissions eq 1){
+
+ if ($filterdb_exists eq 0){
+ $error = "FilterDatabaseInvalidPermissionsSet";
+ return;
+ }
+
+ }
+
+ # Check if certain values are undefined and if they
+ # are then set them blank.
+
+ if (!$filter_find){
+
+ $filter_find = "";
+
+ }
+
+ if (!$filter_replace){
+
+ $filter_replace = "";
+
+ }
+
+ if (!$filter_priority){
+
+ $filter_priority = 1;
+
+ }
+
+ if (!$filter_notes){
+
+ $filter_notes = "";
+
+ }
+
+ my $directory_permissions = main::kiriwrite_filepermissions(".", 1, 1, 0);
+
+ if ($directory_permissions eq 1 && $filterdb_exists){
+
+ # The template database cannot be created because of invalid directory
+ # permissions so return an error value.
+
+ $error = "FilterDatabaseFileUncreateable";
+ return;
+
+ }
+
+ # Check if the filter table exists.
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('SELECT id FROM kiriwrite_filters ORDER BY id ASC') or ( $nofiltertable = 1 );
+
+ # Check if there is really no filter table.
+
+ if ($nofiltertable){
+
+ # Create the filter database table.
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('CREATE TABLE kiriwrite_filters (
+ id int(7) primary key,
+ priority int(5),
+ findsetting varchar(1024),
+ replacesetting varchar(1024),
+ notes text
+ )') or ( $error = "FilterDatabaseError", $errorext = $filterdb_database_handle->errstr, return );
+ $filterdb_string_handle->execute();
+
+ }
+
+ # Find the lowest filter identification number available.
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('SELECT id FROM kiriwrite_filters ORDER BY id ASC') or ( $error = "FilterDatabaseError", $errorext = $filterdb_database_handle->errstr, return );
+ $filterdb_string_handle->execute();
+
+ while (@database_filters = $filterdb_string_handle->fetchrow_array()){
+
+ $filter_id = $database_filters[0];
+
+ # Add the filter identification to the list of filter IDs.
+
+ push(@filterid_list, $filter_id);
+
+ }
+
+ $filter_id = "";
+
+ # Process each filter looking for a blank available filter.
+
+ foreach $filter_id (@filterid_list){
+
+ # Check the next filter ID to see if it's blank.
+
+ $new_id = $filter_id + 1;
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('SELECT id FROM kiriwrite_filters WHERE id = \'' . $class->convert($new_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $filterdb_database_handle->errstr, return );
+ $filterdb_string_handle->execute();
+
+ # Get the filter identification number.
+
+ while (@filterid_check = $filterdb_string_handle->fetchrow_array()){
+
+ $filter_found = 1;
+
+ }
+
+ # Check if a filter was found.
+
+ if (!$filter_found){
+
+ # No filter was found using this ID so exit the loop.
+
+ last;
+
+ }
+
+ # Increment the filter count and reset the filter found value.
+
+ $filter_count++;
+ $filter_found = 0;
+ $new_id = 0;
+
+ }
+
+ # Check if there were any filters in the filters database.
+
+ if (!$filter_count && !$new_id){
+
+ # There were no filters in the filters database so set
+ # the new filter identification value to 1.
+
+ $new_id = 1;
+
+ }
+
+ # Add the filter to the filter database.
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('INSERT INTO kiriwrite_filters (id, priority, findsetting, replacesetting, notes) VALUES (
+ \'' . $class->convert($new_id) . '\',
+ \'' . $class->convert($filter_priority) . '\',
+ \'' . $class->convert($filter_find) . '\',
+ \'' . $class->convert($filter_replace) .'\',
+ \'' . $class->convert($filter_notes) . '\'
+ )') or ( $error = "FilterDatabaseError", $errorext = $filterdb_database_handle->errstr, return );
+ $filterdb_string_handle->execute();
+
+}
+
+sub editfilter{
+#################################################################################
+# editfilter: Edits a filter in the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->editfilter(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# FilterID Specifies the filter to edit. #
+# NewFindFilter Specifies the new find filter setting. #
+# NewReplaceFilter Specifies the new replace filter setting. #
+# NewFilterPriority Specifies the new filter priority setting. #
+# NewFilterNotes Specifies the new notes for the filter. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my @filter_data;
+ my $filter_exists = 1;
+ my $blankfile = 0;
+
+ # Get the values from the hash.
+
+ my $filter_id = $passedoptions->{"FilterID"};
+ my $filter_newfind = $passedoptions->{"NewFindFilter"};
+ my $filter_newreplace = $passedoptions->{"NewReplaceFilter"};
+ my $filter_newpriority = $passedoptions->{"NewFilterPriority"};
+ my $filter_newnotes = $passedoptions->{"NewFilterNotes"};
+
+ # Check if the filter database permissions are valid.
+
+ my $filterdb_exists = main::kiriwrite_fileexists("filters.db.sqlite", 1, 1);
+ my $filterdb_permissions = main::kiriwrite_filepermissions("filters.db.sqlite", 1, 1);
+
+ if ($filterdb_permissions eq 1){
+
+ if ($filterdb_exists eq 0){
+ $error = "FilterDatabaseInvalidPermissionsSet";
+ return;
+ }
+
+ }
+
+ # Check if the filter exists before editing it.
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('SELECT id FROM kiriwrite_filters where id = \'' . $class->convert($filter_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $filterdb_database_handle->errstr, return );
+ $filterdb_string_handle->execute();
+
+ # Check if the filter exists.
+
+ while (@filter_data = $filterdb_string_handle->fetchrow_array()){
+
+ $filter_exists = 1;
+
+ }
+
+ # Check if the filter really does exist.
+
+ if (!$filter_exists){
+
+ # The filter does not exist so return
+ # an error value.
+
+ $error = "FilterDoesNotExist";
+ return;
+
+ }
+
+ # Edit the selected filter.
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('UPDATE kiriwrite_filters SET
+ findsetting = \'' . $class->convert($filter_newfind) . '\',
+ replacesetting = \'' . $class->convert($filter_newreplace) . '\',
+ priority = \'' . $class->convert($filter_newpriority) . '\',
+ notes = \'' . $class->convert($filter_newnotes) . '\'
+ WHERE id = \'' . $class->convert($filter_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $filterdb_database_handle->errstr, return );
+ $filterdb_string_handle->execute();
+
+ undef $filterdb_string_handle;
+ return;
+
+}
+
+sub deletefilter{
+#################################################################################
+# deletefilter: Deletes a filter from the filter database. #
+# #
+# Usage: #
+# #
+# $dbmodule->deletefilter(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# FilterID Specifies the filter to delete from the filter database. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the values passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my $filter_exists = 0;
+ my @filter_data;
+
+ # Get the values from the hash.
+
+ my $filter_id = $passedoptions->{"FilterID"};
+
+ # Check if the filter exists before deleting.
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('SELECT id FROM kiriwrite_filters where id = \'' . $class->convert($filter_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $filterdb_database_handle->errstr, return );
+ $filterdb_string_handle->execute();
+
+ while (@filter_data = $filterdb_string_handle->fetchrow_array()){
+
+ $filter_exists = 1;
+
+ }
+
+ # Check to see if the filter really does exist.
+
+ if (!$filter_exists){
+
+ $error = "FilterDoesNotExist";
+ return;
+
+ }
+
+ # Delete the filter from the filter database.
+
+ $filterdb_string_handle = $filterdb_database_handle->prepare('DELETE FROM kiriwrite_filters where id = \'' . $class->convert($filter_id) . '\'') or ( $error = "FilterDatabaseError", $errorext = $filterdb_database_handle->errstr, return );
+ $filterdb_string_handle->execute();
+
+ undef $filterdb_string_handle;
+
+}
+
+#################################################################################
+# Template subroutines. #
+#################################################################################
+
+sub connecttemplate{
+#################################################################################
+# connecttemplate: Connect to the template database. #
+# #
+# Usage: #
+# #
+# $dbmodule->connecttemplate(missingignore); #
+# #
+# missingignore Ignore errror about database being missing. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ my $class = shift;
+ my $ignoremissing = shift;
+
+ # Check if the template database exists.
+
+ my $templatedatabase_exists = main::kiriwrite_fileexists("templates.db.sqlite");
+
+ if ($templatedatabase_exists eq 1){
+
+ $templatedb_exists = 0;
+
+ if (!$ignoremissing){
+
+ $error = "TemplateDatabaseDoesNotExist";
+ return;
+
+ }
+
+ }
+
+ # Check if the permission settings for the template database are valid.
+
+ my $templatedb_permissions = main::kiriwrite_filepermissions("templates.db.sqlite", 1, 0);
+
+ if ($templatedb_permissions eq 1){
+
+ # The template database has invalid permissions set
+ # so return an error value.
+
+ if (!$ignoremissing){
+
+ $error = "TemplateDatabaseInvalidPermissionsSet";
+ return;
+
+ }
+
+ }
+
+ # Connect to the template database.
+
+ $template_database_handle = DBI->connect("dbi:SQLite:dbname=templates.db.sqlite");
+ $database_handle->{unicode} = 1;
+ $templatedb_loaded = 1;
+
+}
+
+sub disconnecttemplate{
+#################################################################################
+# disconnecttemplate: Disconnect from the template database. #
+# #
+# Usage: #
+# #
+# $dbmodule->disconnecttemplate(); #
+#################################################################################
+
+ # Disconnect the template database.
+
+ if ($templatedb_loaded eq 1){
+
+ undef $template_string_handle;
+ $template_database_handle->disconnect();
+
+ }
+
+}
+
+sub gettemplatelist{
+#################################################################################
+# gettemplatelist: Gets the list of templates. #
+# #
+# Usage: #
+# #
+# $dbmodule->gettemplatelist(); #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ $template_string_handle = $template_database_handle->prepare('SELECT filename FROM kiriwrite_templates ORDER BY filename ASC') or ( $error = "TemplateDatabaseError", $errorext = $template_database_handle->errstr, return );
+ $template_string_handle->execute();
+
+ my @database_template;
+ my @templates_list;
+ my $template_filename;
+
+ while (@database_template = $template_string_handle->fetchrow_array()){
+
+ # Get certain values from the array.
+
+ $template_filename = $database_template[0];
+
+ # Add the template to the list of templates.
+
+ push(@templates_list, $template_filename);
+
+ }
+
+ return @templates_list;
+
+}
+
+sub gettemplateinfo{
+#################################################################################
+# gettemplateinfo: Get information on a template. #
+# #
+# Usage: #
+# #
+# $dbmodule->gettemplateinfo(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# TemplateFilename Specifies the template filename to use. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my %page_info;
+ my @template_data;
+
+ my $template_filename;
+ my $template_name;
+ my $template_description;
+ my $template_datemodified;
+ my $template_layout;
+
+ my $template_found = 0;
+
+ my $filename = $passedoptions->{"TemplateFilename"};
+
+ $template_string_handle = $template_database_handle->prepare('SELECT filename, templatename, templatedescription, templatelayout, datemodified FROM kiriwrite_templates WHERE filename = \'' . $class->convert($filename) . '\'') or ( $error = "TemplateDatabaseError", $errorext = $template_database_handle->errstr, return );
+ $template_string_handle->execute();
+
+ while (@template_data = $template_string_handle->fetchrow_array()){
+
+ # Get certain values from the array.
+
+ $template_filename = $template_data[0];
+ $template_name = $template_data[1];
+ $template_description = $template_data[2];
+ $template_layout = $template_data[3];
+ $template_datemodified = $template_data[4];
+
+ # Process them into the hash.
+
+ %page_info = (
+ "TemplateFilename" => $template_filename,
+ "TemplateName" => $template_name,
+ "TemplateDescription" => $template_description,
+ "TemplateLayout" => $template_layout,
+ "TemplateLastModified" => $template_datemodified
+ );
+
+ $template_found = 1;
+
+ }
+
+ if ($template_found eq 0){
+
+ # The template was not found in the template database so
+ # write an error value.
+
+ $error = "TemplateDoesNotExist";
+ return;
+
+ }
+
+ return %page_info;
+
+}
+
+sub addtemplate{
+#################################################################################
+# addtemplate: Adds a template to the template database. #
+# #
+# Usage: #
+# #
+# $dbmodule->addtemplate(); #
+# #
+# options Specifies the following options in any order. #
+# #
+# TemplateFilename Specifies the new template filename. #
+# TemplateName Specifies the new template name. #
+# TemplateDescription Specifies the new template description. #
+# TemplateLayout Specifies the new template layout. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my @page_exists;
+ my $notemplatetable;
+ my $blankfile = 0;
+
+ my $template_filename = $passedoptions->{"TemplateFilename"};
+ my $template_name = $passedoptions->{"TemplateName"};
+ my $template_description = $passedoptions->{"TemplateDescription"};
+ my $template_layout = $passedoptions->{"TemplateLayout"};
+
+ # Check if the template database permissions are valid.
+
+ my $templatedb_exists = main::kiriwrite_fileexists("templates.db.sqlite", 1, 1);
+ my $templatedb_permissions = main::kiriwrite_filepermissions("templates.db.sqlite", 1, 1);
+
+ if ($templatedb_permissions eq 1){
+
+ if ($templatedb_exists eq 0){
+ $error = "TemplateDatabaseInvalidPermissionsSet";
+ return;
+ }
+
+ }
+
+ # Check if the template already exists before adding.
+
+ if ($templatedb_exists eq 0){
+
+ $template_string_handle = $template_database_handle->prepare('SELECT filename FROM kiriwrite_templates WHERE filename = \'' . $class->convert($template_filename) . '\' LIMIT 1') or ($blankfile = 1);
+
+ if ($blankfile eq 0){
+
+ $template_string_handle->execute();
+
+ while (@page_exists = $template_string_handle->fetchrow_array()){
+
+ $error = "TemplatePageExists";
+ return;
+
+ }
+
+ }
+
+ }
+
+ # Get the current date.
+
+ my ($created_second, $created_minute, $created_hour, $created_day, $created_month, $created_year, $created_weekday, $created_yearday, $created_dst) = localtime;
+
+ my $template_date = $created_year . '-' . $created_month . '-' . $created_day . ' ' . $created_hour . ':' . $created_minute . ':' . $created_second;
+
+ # Check if certain values are undefined and if they
+ # are then set them blank.
+
+ if (!$template_name){
+
+ $template_name = "";
+
+ }
+
+ if (!$template_description){
+
+ $template_description = "";
+
+ }
+
+ if (!$template_layout){
+
+ $template_layout = "";
+
+ }
+
+ my $directory_permissions = main::kiriwrite_filepermissions(".", 1, 1, 0);
+
+ if ($directory_permissions eq 1 && $templatedb_exists){
+
+ # The template database cannot be created because of invalid directory
+ # permissions so return an error value.
+
+ $error = "TemplateDatabaseUncreateable";
+ return;
+
+ }
+
+ # Check to see if a template can be added.
+
+ $template_string_handle = $template_database_handle->prepare('INSERT INTO kiriwrite_templates (filename, templatename, templatedescription, templatelayout, datemodified) VALUES(
+ \'' . $class->convert($template_filename) . '\',
+ \'' . $class->convert($template_name) . '\',
+ \'' . $class->convert($template_description) . '\',
+ \'' . $class->convert($template_layout) . '\',
+ \'' . $class->convert($template_date) . '\'
+ )') or ( $notemplatetable = 1 );
+
+ if (!$notemplatetable){
+
+ $template_string_handle->execute();
+
+ }
+
+ # Check to see if there is no template table and attempt to create one.
+
+ if ($notemplatetable){
+
+ # Create a template table.
+
+ my $directory_permissions = main::kiriwrite_filepermissions(".", 1, 1, 0);
+
+ if ($directory_permissions eq 1){
+
+ # The template database cannot be created because of invalid directory
+ # permissions so return an error.
+
+ $error = "TemplateDatabaseFileUncreateable";
+ return;
+
+ }
+
+ $template_string_handle = $template_database_handle->prepare('create table kiriwrite_templates(
+ filename varchar(256) primary key,
+ templatename varchar(512),
+ templatedescription varchar(512),
+ templatelayout text,
+ datemodified datetime
+ );') or ( $error = "TemplateDatabaseError", $errorext = $template_database_handle->errstr, return );
+ $template_string_handle->execute();
+
+ $template_string_handle = $template_database_handle->prepare('INSERT INTO kiriwrite_templates (filename, templatename, templatedescription, templatelayout, datemodified) VALUES(
+ \'' . $class->convert($template_filename) . '\',
+ \'' . $class->convert($template_name) . '\',
+ \'' . $class->convert($template_description) . '\',
+ \'' . $class->convert($template_layout) . '\',
+ \'' . $class->convert($template_date) . '\'
+ )') or ( $error = "TemplateDatabaseError", $errorext = $template_database_handle->errstr, return );
+ $template_string_handle->execute();
+
+ }
+
+}
+
+sub deletetemplate{
+#################################################################################
+# deletetemplate: Deletes a template from the template database. #
+# #
+# Usage: #
+# #
+# $dbmodule->deletetemplate(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# TemplateFilename Specifies the template filename to delete. #
+#################################################################################
+
+ $error = "";
+ $errorext = "";
+
+ # Get the data passed to the subroutine.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+
+ my @pagedata;
+ my $template_filename = $passedoptions->{"TemplateFilename"};
+ my $template_count = 0;
+
+ # Check if the template exists.
+
+ $template_string_handle = $template_database_handle->prepare('SELECT filename FROM kiriwrite_templates WHERE filename = \'' . $class->convert($template_filename) . '\' LIMIT 1') or ( $error = "TemplateDatabaseError", $errorext = $template_database_handle->errstr, return );
+ $template_string_handle->execute();
+
+ while (@pagedata = $template_string_handle->fetchrow_array()){
+
+ $template_count++;
+
+ }
+
+ if ($template_count eq 0){
+
+ # No pages were returned so return an error value.
+
+ $error = "TemplateDoesNotExist";
+ return;
+
+ }
+
+ # Delete the template from the template database.
+
+ $template_string_handle = $template_database_handle->prepare('DELETE FROM kiriwrite_templates WHERE filename = \'' . $class->convert($template_filename) . '\'') or ( $error = "TemplateDatabaseError", $errorext = $template_database_handle->errstr, return );
+ $template_string_handle->execute();
+
+}
+
+sub edittemplate{
+#################################################################################
+# editttemplate: Edits a Kiriwrite template. #
+# #
+# Usage: #
+# #
+# $dbmodule->edittemplate(options); #
+# #
+# options Specifies the following options in any order. #
+# #
+# TemplateFilename Specifies the template filename to edit. #
+# NewTemplateFilename Specifies the new template filename. #
+# NewTemplateName Specifies the new template name. #
+# NewTemplateDescription Specifies the new template description. #
+# NewTemplateLayout Specifies the new template layout. #
+#################################################################################
+
+ # Get the values passed.
+
+ my $class = shift;
+ my ($passedoptions) = @_;
+ my $template_found = 0;
+ my @template_info;
+
+ # Process the values passed.
+
+ my $template_filename = $passedoptions->{"TemplateFilename"};
+ my $new_template_filename = $passedoptions->{"NewTemplateFilename"};
+ my $new_template_name = $passedoptions->{"NewTemplateName"};
+ my $new_template_description = $passedoptions->{"NewTemplateDescription"};
+ my $new_template_layout = $passedoptions->{"NewTemplateLayout"};
+
+ # Check if the template database permissions are valid.
+
+ my $templatedb_exists = main::kiriwrite_fileexists("templates.db.sqlite", 1, 1);
+ my $templatedb_permissions = main::kiriwrite_filepermissions("templates.db.sqlite", 1, 1);
+
+ if ($templatedb_permissions eq 1){
+
+ if ($templatedb_exists eq 0){
+ $error = "TemplateDatabaseInvalidPermissionsSet";
+ return;
+ }
+
+ }
+
+ # Check if the template exists.
+
+ $template_string_handle = $template_database_handle->prepare('SELECT filename FROM kiriwrite_templates WHERE filename = \'' . $class->convert($template_filename) . '\' LIMIT 1') or ( $error = "TemplateDatabaseError", $errorext = $template_database_handle->errstr, return );
+ $template_string_handle->execute();
+
+ while (@template_info = $template_string_handle->fetchrow_array()){
+
+ $template_found = 1;
+
+ }
+
+ # Check to see if the template was found and set an error value if
+ # it wasn't.
+
+ if ($template_found eq 0){
+
+ $error = "TemplateDoesNotExist";
+ return;
+
+ }
+
+ # Get the date and time.
+
+ my ($created_second, $created_minute, $created_hour, $created_day, $created_month, $created_year, $created_weekday, $created_yearday, $created_dst) = localtime;
+ my $templatenewdate = $created_year . '-' . $created_month . '-' . $created_day . ' ' . $created_hour . ':' . $created_minute . ':' . $created_second;
+
+ # Update the template information.
+
+ $template_string_handle = $template_database_handle->prepare('UPDATE kiriwrite_templates SET
+ filename = \'' . $class->convert($new_template_filename) . '\',
+ templatename = \'' . $class->convert($new_template_name) . '\',
+ templatedescription = \'' . $class->convert($new_template_description) . '\',
+ templatelayout = \'' . $class->convert($new_template_layout) . '\',
+ datemodified = \'' . $class->convert($templatenewdate) . '\'
+ WHERE filename = \'' . $class->convert($template_filename) . '\'
+ ') or ( $error = "TemplateDatabaseError", $errorext = $template_database_handle->errstr, return );
+ $template_string_handle->execute();
+
+}
+
+#################################################################################
+# General subroutines. #
+#################################################################################
+
+sub connect{
+#################################################################################
+# connect: Connect to the server. #
+# #
+# Usage: #
+# #
+# $dbmodule->connect(); #
+#################################################################################
+
+ # This function is not needed in this database module.
+
+}
+
+sub disconnect{
+#################################################################################
+# connect: Disconnect from the server. #
+# #
+# Usage: #
+# #
+# $dbmodule->disconnect(); #
+#################################################################################
+
+ # This function is not needed in this database module.
+
+ undef $string_handle;
+
+}
+
+1;
\ No newline at end of file
--- /dev/null
+#################################################################################
+# Kiriwrite Presentation Module - HTML 4.0 Strict (HTML4S.pm) #
+# Output Module for writing pages to the HTML 4.0 Strict Standard #
+# #
+# Copyright (C) 2007 Steve Brokenshire <sbrokenshire@xestia.co.uk> #
+# #
+# This module is licensed under the same license as Kiriwrite which is the GPL. #
+# #
+# This program is free software; you can redistribute it and/or modify it under #
+# the terms of the GNU General Public License as published by the Free #
+# Software Foundation; as version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.#
+# #
+# You should have received a copy of the GNU General Public License along with #
+# this program; if not, write to the Free Software Foundation, Inc., 51 #
+# Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
+#################################################################################
+
+# Define the package (perl module) name.
+
+package Kiriwrite::Presentation::HTML4S;
+
+# Enable strict and use warnings.
+
+use strict;
+use warnings;
+
+# Set the following values.
+
+our $VERSION = "0.1.0";
+my $pagedata = "";
+my $tablevel = 0;
+
+#################################################################################
+# Generic Subroutines. #
+#################################################################################
+
+sub new{
+#################################################################################
+# new: Create an instance of Kiriwrite::Presentation::HTML4S #
+# #
+# Usage: #
+# #
+# $presmodule = Modules::Output::HTML4S->new(); #
+#################################################################################
+
+ # Get the perl module name.
+
+ my $class = shift;
+ my $self = {};
+
+ return bless($self, $class);
+
+}
+
+sub clear{
+#################################################################################
+# clear: Clear the current layout created by this module. #
+# #
+# Usage: #
+# #
+# $presmodule->clear(); #
+#################################################################################
+
+ $pagedata = "";
+ return;
+
+}
+
+sub grab{
+#################################################################################
+# grab: Grab the current layout created by this module. #
+# #
+# Usage: #
+# #
+# $presmodule->grab(); #
+#################################################################################
+
+ return $pagedata;
+
+}
+
+sub convert{
+#################################################################################
+# convert: Converts the data passed into data that is compliant with the output #
+# format. #
+# #
+# Usage: #
+# #
+# $presmodule->convert(data, type); #
+# #
+# data Specifies the data to be converted. #
+# type Specifies the type the data should be converted to. #
+#################################################################################
+
+ # Get the data and type passed.
+
+ my $class = shift;
+ my ($data, $type) = @_;
+
+ # Check if certain values are undefined and if they are
+ # then set them blank or return an error.
+
+ if (!$data){
+ $data = "";
+ }
+
+ if (!$type){
+ die("No type was specified");
+ }
+
+ # Check what type is being used and process the data
+ # according the type being used.
+
+ if ($type eq "content"){
+
+ $data =~ s/&/&/g;
+ $data =~ s/#/#/g;
+ $data =~ s/\"/"/g;
+ $data =~ s/'/'/g;
+ $data =~ s/>/>/g;
+ $data =~ s/</</g;
+ $data =~ s/\+/+/g;
+ $data =~ s/-/-/g;
+ $data =~ s/_/_/g;
+ $data =~ s/\@/@/g;
+ $data =~ s/~/~/g;
+ $data =~ s/\?/?/g;
+ $data =~ s/'/'/g;
+ $data =~ s/\0//g;
+ $data =~ s/\b//g;
+
+ } elsif ($type eq "link"){
+
+ $data =~ s/&/&/g;
+ $data =~ s/\+/\%2B/g;
+ $data =~ s/\?/\%3F/g;
+ $data =~ s/%3F/\?/;
+ $data =~ s/-/\%2D/g;
+ $data =~ s/_/\%5F/g;
+ $data =~ s/\@/\%40/g;
+ $data =~ s/#/\%23/g;
+ $data =~ s/>/\%3E/g;
+ $data =~ s/</\%3C/g;
+ $data =~ s/~/\%7E/g;
+ $data =~ s/'/\%27/;
+ $data =~ s/!/\%21/g;
+
+ } else {
+
+ die("An invalid type was specified.");
+
+ }
+
+ return $data;
+
+}
+
+#################################################################################
+# Tags for creating tables. #
+#################################################################################
+
+sub starttable{
+#################################################################################
+# starttable: Start a table. #
+# #
+# Usage: #
+# #
+# $presmodule->starttable(cssstyle, {options}); #
+# #
+# cssstyle Specifies the CSS style name to use. #
+# options Specifies the following options (in any order): #
+# #
+# CellPadding The cell padding to be used for each table. #
+# CellSpacing The cell spacing to be used for each table. #
+#################################################################################
+
+ # Get the CSS style and options.
+
+ my $class = shift;
+ my ($cssstyle, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ my $cellpadding = $options->{'CellPadding'};
+ my $cellspacing = $options->{'CellSpacing'};
+
+ # Check if the cell padding and cell spacing and
+ # CSS style values are blank and if they are then
+ # set them blank.
+
+ if (!$cellpadding){
+ $cellpadding = 0;
+ }
+
+ if (!$cellspacing){
+ $cellspacing = 0;
+ }
+
+ if (!$cssstyle){
+ $cssstyle = "";
+ }
+
+ # Check if the cell padding and cell spacing values
+ # are valid and die if it isn't.
+
+ my $cellpadding_validated = $cellpadding;
+ my $cellspacing_validated = $cellspacing;
+
+ $cellpadding_validated =~ tr/0-9//d;
+ $cellspacing_validated =~ tr/0-9//d;
+
+ if ($cellpadding_validated ne ""){
+ die("Cell padding value given is invalid.");
+ }
+
+ if ($cellspacing_validated ne ""){
+ die("Cell spacing value given is invalid.");
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Start a table.
+
+ $tagdata = $tagdata . "<table";
+
+ # Check if the cell spacing and cell padding has values
+ # more than 0.
+
+ if ($cellspacing >= 0){
+ $tagdata = $tagdata . " cellspacing=\"" . $cellspacing . "\"";
+ }
+
+ if ($cellpadding > 0){
+ $tagdata = $tagdata . " cellpadding=\"" . $cellpadding . "\"";
+ }
+
+ if ($cssstyle ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($cssstyle, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+ $tablevel++;
+
+}
+
+sub startheader{
+#################################################################################
+# startheader: Start a table header. #
+# #
+# Usage: #
+# #
+# $presmodule->startheader(); #
+#################################################################################
+
+ # Start a table header row.
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "<tr>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+ $tablevel++;
+
+}
+
+sub addheader{
+#################################################################################
+# addheader: Add a table header. #
+# #
+# Usage: #
+# #
+# $presmodule->addheader(headername, {options}); #
+# #
+# headername Specifies the name of the table header to use. #
+# options Specifies the following options below (in any order): #
+# #
+# Style Specifies the CSS Style to use for the table header. #
+#################################################################################
+
+ # Get the header name and options.
+
+ my $class = shift;
+ my ($headername, $options) = @_;
+
+ my $cssstyle = $options->{'Style'};
+
+ # Check if the CSS Style or header name is undefined and
+ # if they are then set them blank.
+
+ if (!$headername){
+ $headername = "";
+ }
+
+ if (!$cssstyle){
+ $cssstyle = "";
+ }
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "<th";
+
+ if ($cssstyle ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($cssstyle, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">" . $class->convert($headername, "content") . "</th>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub endheader{
+#################################################################################
+# endheader: End a table header row #
+# #
+# Usage: #
+# #
+# $presmodule->endheader(); #
+#################################################################################
+
+ # End a table header row.
+
+ my $tagdata = "";
+ $tablevel = ($tablevel - 1);
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "</tr>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub startrow{
+#################################################################################
+# startrow: Start a table row. #
+# #
+# Usage: #
+# #
+# $presmodule->startrow(); #
+#################################################################################
+
+ # Start a table row.
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "<tr>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+ $tablevel++;
+
+}
+
+sub addcell{
+#################################################################################
+# addcell: Add a table cell. #
+# #
+# Usage: #
+# #
+# $presmodule->addcell(style); #
+# #
+# style Specifies which CSS Style to use. #
+#################################################################################
+
+ # Get the cell information and options.
+
+ my $class = shift;
+ my ($cssstyle) = @_;
+ my $tabcount = $tablevel;
+ my $tagdata = "";
+
+ # Check if the cell data and CSS style are undefined
+ # and if they are then set them blank.
+
+ if (!$cssstyle){
+ $cssstyle = "";
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "<td";
+
+ if ($cssstyle ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($cssstyle, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub endcell{
+#################################################################################
+# endcell: End a table cell. #
+# #
+# Usage: #
+# #
+# $presmodule->endcell(); #
+#################################################################################
+
+ # End a table cell.
+
+ my $tagdata = "";
+
+ $tagdata = $tagdata . "</td>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub endrow{
+#################################################################################
+# endrow: Ends a table row. #
+# #
+# Usage: #
+# #
+# $presmodule->endrow(); #
+#################################################################################
+
+ # End a table row.
+
+ my $tagdata = "";
+ $tablevel = ($tablevel - 1);
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "</tr>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub endtable{
+#################################################################################
+# endtable: Ends a table. #
+# #
+# Usage: #
+# #
+# $presmodule->endtable(); #
+#################################################################################
+
+ # End a table.
+
+ my $tagdata = "";
+ $tablevel = ($tablevel - 1);
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "</table>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+#################################################################################
+# Information box. #
+#################################################################################
+
+sub startbox{
+#################################################################################
+# startbox: Start an information box. #
+# #
+# Usage: #
+# #
+# $presmodule->startbox(cssstyle); #
+# #
+# cssstyle Specifies the CSS Style to use. #
+#################################################################################
+
+ # Get the CSS Style name.
+
+ my $class = shift;
+ my $cssstyle = shift;
+
+ # Check if the CSS style given is undefined and
+ # if it is then set it blank.
+
+ if (!$cssstyle){
+ $cssstyle = "";
+ }
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Start an information box.
+
+ $tagdata = $tagdata . "<div";
+
+ if ($cssstyle ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($cssstyle, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub enterdata{
+#################################################################################
+# enterdata: Enter data into a information box. #
+# #
+# Usage: #
+# #
+# $presmodule->enterdata(data); #
+# #
+# data Specifies what data should be entered into the information box. #
+#################################################################################
+
+ # Get the data for the information box.
+
+ my $class = shift;
+ my $data = shift;
+
+ # Append the data to the page data.
+
+ $pagedata = $pagedata . $class->convert($data, "content");
+
+}
+
+sub endbox{
+#################################################################################
+# endbox: End an information box. #
+# #
+# Usage: #
+# #
+# $presmodule->endbox(); #
+#################################################################################
+
+ # End an information box.
+
+ my $tagdata = "";
+ $tagdata = $tagdata . "</div>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+#################################################################################
+# Form boxes. #
+#################################################################################
+
+sub startform{
+#################################################################################
+# startform: Start a form. #
+# #
+# Usage: #
+# #
+# $presmodule->startform(action, method); #
+# #
+# action Specifies the action (address) the data should be sent to. #
+# method Specifies the method to use (POST, GET) #
+#################################################################################
+
+ my $class = shift;
+ my $action = shift;
+ my $method = shift;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Check if the action and method values given
+ # are undefined and if they are set default
+ # values.
+
+ if (!$action){
+ $action = "";
+ }
+
+ if (!$method){
+ # The method is blank so set it to POST.
+ $method = "POST";
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "<form action=\"" . $class->convert($action, "content") . "\" method=\"" . $class->convert($method, "content") . "\">" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+ $tablevel++;
+
+}
+
+sub addcheckbox{
+#################################################################################
+# addcheckbox: Add a check box. #
+# #
+# Usage: #
+# #
+# $presmodule->addcheckbox(checkboxname, {options}); #
+# #
+# checkboxname Specifies the check box name. #
+# options Specifies the following options below (in any order). #
+# #
+# OptionDescription Specifies a description for the checkbox value. #
+# Style Specifies the CSS style to use. #
+# Checked Specifies if the checkbox is checked. #
+# LineBreak Specifies if a line break should be added. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($checkboxname, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $optiondescription = $options->{'OptionDescription'};
+ my $style = $options->{'Style'};
+ my $checked = $options->{'Checked'};
+ my $linebreak = $options->{'LineBreak'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$checkboxname){
+ die("The checkbox name is blank.");
+ }
+
+ if (!$optiondescription){
+ $optiondescription = "";
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ if (!$checked){
+ $checked = 0;
+ }
+
+ if (!$linebreak){
+ $linebreak = 0;
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add a check box.
+
+ $tagdata = $tagdata . "<input type=\"checkbox\" name=\"" . $class->convert($checkboxname, "content") . "\"";
+
+ if ($style ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ if ($checked eq 1){
+ $tagdata = $tagdata . " checked";
+ }
+
+ $tagdata = $tagdata . ">";
+
+ if ($optiondescription ne ""){
+ $tagdata = $tagdata . " " . $class->convert($optiondescription, "content");
+ }
+
+ if ($linebreak eq 1){
+ $tagdata = $tagdata . "<br>";
+ }
+
+ $tagdata = $tagdata . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub addradiobox{
+#################################################################################
+# addradiobox: Add a radio box. #
+# #
+# Usage: #
+# #
+# $presmodule->addradiobox(radioboxname, {options}); #
+# #
+# radioboxname The name of the radio box. #
+# options Specifies the following options below (in any order). #
+# #
+# Description Specifies a description for the checkbox value. #
+# Style Specifies the CSS style to use. #
+# Selected Specifies if the radio box is selected. #
+# LineBreak Specifies if a line break should be used. #
+# Value Specifies the value of the radio box. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($radioboxname, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $optiondescription = $options->{'Description'};
+ my $style = $options->{'Style'};
+ my $selected = $options->{'Selected'};
+ my $linebreak = $options->{'LineBreak'};
+ my $value = $options->{'Value'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$radioboxname){
+ die("The radio box name is blank.");
+ }
+
+ if (!$value){
+ $value = "";
+ }
+
+ if (!$optiondescription){
+ $optiondescription = "";
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ if (!$selected){
+ $selected = 0;
+ }
+
+ if (!$linebreak){
+ $linebreak = 0;
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add a radio box.
+
+ $tagdata = $tagdata . "<input type=\"radio\" name=\"" . $class->convert($radioboxname, "content") . "\"";
+
+ if ($style ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ if ($selected eq 1){
+ $tagdata = $tagdata . " checked";
+ }
+
+ if ($value ne ""){
+ $tagdata = $tagdata . " value=\"" . $class->convert($value, "content") . "\"";
+ } else {
+ $tagdata = $tagdata . " value=\"0\"";
+ }
+
+ $tagdata = $tagdata . ">";
+
+ if ($optiondescription ne ""){
+ $tagdata = $tagdata . " " . $class->convert($optiondescription, "content");
+ }
+
+ if ($linebreak eq 1){
+ $tagdata = $tagdata . "<br>";
+ }
+
+ $tagdata = $tagdata . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+}
+
+sub addselectbox{
+#################################################################################
+# addselectbox: Add a select box. #
+# #
+# Usage: #
+# #
+# $presmodule->addselectbox(selectname, {options}); #
+# #
+# selectboxname Specifies the name of the select box. #
+# options Specifies the following options (in any order). #
+# #
+# Style Specifies the CSS style to use. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($selectboxname, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $style = $options->{'Style'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$selectboxname){
+ die("The select box name is blank.")
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add a select box.
+
+ $tagdata = $tagdata . "<select name=\"" . $class->convert($selectboxname, "content") . "\"";
+
+ if ($style ne ""){
+ $tagdata = $tagdata = " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+ $tablevel++;
+
+}
+
+sub addoption{
+#################################################################################
+# addoption: Add an option for a select box. #
+# #
+# Usage: #
+# #
+# $presmodule->addoption(optionname, options); #
+# #
+# optionname Specifies the name (description) of the option. #
+# options Specifies the following options (in any order). #
+# #
+# Style Specifies the CSS style to be used. #
+# Value Specifies the value of the option. #
+# Selected This option is selected as default when the page is displayed. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($optionname, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $style = $options->{'Style'};
+ my $value = $options->{'Value'};
+ my $selected = $options->{'Selected'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$optionname){
+ die("The option name given is blank.");
+ }
+
+ if (!$value){
+ die("No value for the option was given.");
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ if (!$selected){
+ $selected = 0;
+ }
+
+ # Check if certain values are valid and return
+ # an error if they aren't.
+
+ my $selected_validated = $selected;
+
+ $selected_validated =~ tr/0-9//d;
+
+ if ($selected_validated ne ""){
+ die("The selection option is invalid.");
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add an option for a select box.
+
+ $tagdata = $tagdata . "<option value=\"" . $class->convert($value, "content") . "\"";
+
+ if ($style ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ if ($selected eq 1){
+ $tagdata = $tagdata . " selected";
+ }
+
+ $tagdata = $tagdata . ">" . $class->convert($optionname, "content") . "</option>\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub endselectbox{
+#################################################################################
+# endselectbox: Ends a select box. #
+# #
+# Usage: #
+# #
+# $presmodule->endselectbox(); #
+#################################################################################
+
+ # End a select box.
+
+ my $tagdata = "";
+ $tablevel = ($tablevel - 1);
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "</select>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub addinputbox{
+#################################################################################
+# addinputbox: Add a input text box. #
+# #
+# Usage: #
+# #
+# $presmodule->addinputbox(inputboxname, options); #
+# #
+# inputboxname Specifies the name of the input text box. #
+# options Specifies the following options (in any order). #
+# #
+# Size Specifies the size of the input text box. #
+# MaxLength Specifies the maximum length of the input text box. #
+# Style Specifies the CSS style to use. #
+# Value Specifies a value for the input box. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($inputboxname, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $size = $options->{'Size'};
+ my $maxlength = $options->{'MaxLength'};
+ my $style = $options->{'Style'};
+ my $value = $options->{'Value'};
+ my $password = $options->{'Password'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$inputboxname){
+ die("The input box name given is blank.");
+ }
+
+ if (!$size){
+ $size = 0;
+ }
+
+ if (!$maxlength){
+ $maxlength = 0;
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ if (!$value){
+ $value = "";
+ }
+
+ if (!$password){
+ $password = 0;
+ }
+
+ # Check if certain values are valid and return
+ # an error if they aren't.
+
+ my $size_validated = $size;
+ my $maxlength_validated = $maxlength;
+
+ $size_validated =~ tr/0-9//d;
+ $maxlength_validated =~ tr/0-9//d;
+
+ if ($size_validated ne ""){
+ die("The size given is invalid.");
+ }
+
+ if ($maxlength_validated ne ""){
+ die("The maximum length given is invalid.");
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add an input text box.
+
+ $tagdata = "<input ";
+
+ # Check if it should be a password field.
+
+ if ($password eq 1){
+
+ # The field should be a password field.
+
+ $tagdata = $tagdata . "type=\"password\" ";
+
+ } else {
+
+ # The field should be a text field.
+
+ $tagdata = $tagdata . "type=\"text\" ";
+
+ }
+
+ $tagdata = $tagdata . "name=\"" . $class->convert($inputboxname, "content") . "\"";
+
+ if ($size > 0){
+ $tagdata = $tagdata . " size=\"" . $class->convert($size, "content") . "\"";
+ }
+
+ if ($maxlength > 0){
+ $tagdata = $tagdata . " maxlength=\"" . $class->convert($maxlength, "content") . "\"";
+ }
+
+ if ($style ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ if ($value ne ""){
+ $tagdata = $tagdata . " value=\"" . $class->convert($value, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub addtextbox{
+#################################################################################
+# addtextbox: Add a multiple line text box. #
+# #
+# Usage: #
+# #
+# $presmodule->addtextbox(textboxname, options); #
+# #
+# textboxname Specifies the name of the multiple line text box. #
+# options Specifies the following options (in any order). #
+# #
+# Columns Specifies the width of the multiple line text box. #
+# Rows Specifies the height of the multiple line text box. #
+# Style Specifies the CSS style to use. #
+# Value Specifies a value for the multiple line text box. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($textboxname, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $columns = $options->{'Columns'};
+ my $rows = $options->{'Rows'};
+ my $style = $options->{'Style'};
+ my $value = $options->{'Value'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$textboxname){
+ die("The multiple line text box name is blank.");
+ }
+
+ if (!$columns){
+ $columns = 0;
+ }
+
+ if (!$rows){
+ $rows = 0;
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ if (!$value){
+ $value = "";
+ }
+
+ # Check if certain values are valid and return
+ # an error if they aren't.
+
+ my $columns_validated = $columns;
+ my $rows_validated = $rows;
+
+ $columns_validated =~ tr/0-9//d;
+ $rows_validated =~ tr/0-9//d;
+
+ if ($columns_validated ne ""){
+ die("The columns value given is invalid.");
+ }
+
+ if ($rows_validated ne ""){
+ die("The rows value given is invalid.");
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add a multiple line text box.
+
+ $tagdata = $tagdata . "<textarea name=\"" . $class->convert($textboxname, "content") . "\"";
+
+ if ($columns > 0){
+ $tagdata = $tagdata . " cols=\"" . $class->convert($columns, "content") . "\"";
+ }
+
+ if ($rows > 0){
+ $tagdata = $tagdata . " rows=\"" . $class->convert($rows, "content") . "\"";
+ }
+
+ if ($style ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">";
+ $tagdata = $tagdata . $value;
+ $tagdata = $tagdata . "</textarea>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub addsubmit{
+#################################################################################
+# addsubmit: Add a submit button. #
+# #
+# Usage: #
+# #
+# $pagemodule->addsubmit(submitname, options); #
+# #
+# submitname Specifies the name (label) of the submit button. #
+# options Specifies the following options (in any order). #
+# #
+# Style Specifies the CSS style to use. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($submitname, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $style = $options->{'Style'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$submitname){
+ die("The submit name is blank.");
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add a submit button.
+
+ $tagdata = $tagdata . "<input type=\"submit\" value=\"" . $class->convert($submitname, "content") . "\"";
+
+ if ($style ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub addreset{
+#################################################################################
+# addreset: Add a reset button. #
+# #
+# Usage: #
+# #
+# $pagemodule->addreset(resetname, options); #
+# #
+# resetname Specifies the name (label) of the reset button. #
+# options Specifies the following options (in any order). #
+# #
+# Style Specifies the CSS style to use. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($resetname, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $style = $options->{'Style'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$resetname){
+ die("The reset name is blank.");
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add a reset button.
+
+ $tagdata = $tagdata . "<input type=\"reset\" value=\"" . $class->convert($resetname, "content") . "\"";
+
+ if ($style ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub addhiddendata{
+#################################################################################
+# addhiddendata: Adds hidden data to the form. #
+# #
+# Usage: #
+# #
+# $presmodule->addhiddendata(name, value); #
+# #
+# name Specifies the name of the hidden data. #
+# value Specifies the value of the hidden data. #
+#################################################################################
+
+ # Get the name and value.
+
+ my $class = shift;
+ my ($name, $value) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$name){
+ die("The name for the hidden data is blank.");
+ }
+
+ if (!$value){
+ $value = "";
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add hidden data.
+
+ $tagdata = $tagdata . "<input type=\"hidden\" name=\"" . $class->convert($name, "content") . "\"";
+
+ if ($value ne ""){
+ $tagdata = $tagdata . " value=\"" . $class->convert($value, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">" . "\r\n";
+
+ # Add the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub addbutton{
+#################################################################################
+# addbutton: Add a button. #
+# #
+# Usage: #
+# #
+# $presmodule->addbutton(buttonname, options); #
+# #
+# buttonname Specifies the name of button. #
+# options Specifies the following options below (in any order). #
+# #
+# Value Specifies the value of the button. #
+# Description Specifies the description (label) of the button. #
+# Style Specifies the CSS style to use. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($buttonname, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $value = $options->{'Value'};
+ my $description = $options->{'Description'};
+ my $style = $options->{'Style'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$buttonname){
+ die("The name for button is blank.");
+ }
+
+ if (!$value){
+ $value = "";
+ }
+
+ if (!$description){
+ die("The description for the button is blank.");
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add a button.
+
+ $tagdata = $tagdata . "<button name=\"" . $class->convert($buttonname, "content") . "\"";
+
+ if ($value ne ""){
+ $tagdata = $tagdata . " value=\"" . $class->convert($value, "content") . "\"";
+ }
+
+ if ($style ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">" . $class->convert($description, "content") . "</button>\r\n";
+
+ # Add the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub endform{
+#################################################################################
+# endform: Ends a form. #
+# #
+# Usage: #
+# #
+# $presmodule->endform(); #
+#################################################################################
+
+ # End a form.
+
+ my $tagdata = "";
+ $tablevel = ($tablevel - 1);
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "</form>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+#################################################################################
+# Page Link. #
+#################################################################################
+
+sub addlink{
+#################################################################################
+# addlink: Adds a link. #
+# #
+# Usage: #
+# #
+# $presmodule->addlink(link, options); #
+# #
+# Link Specifies the location of the link. #
+# options Specifies the following options below (in any order). #
+# #
+# Target Specifies the target window for the link. #
+# Text Specifies the text to use. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($link, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $target = $options->{'Target'};
+ my $name = $options->{'Text'};
+ my $embed = $options->{'Embed'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$link){
+ die("The link specified was blank.");
+ }
+
+ if (!$target){
+ $target = "";
+ }
+
+ if (!$embed){
+ $embed = 0;
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add a link.
+
+ $tagdata = "<a href=\"" . $class->convert($link, "link") . "\"";
+
+ if ($target ne ""){
+ $tagdata = $tagdata . " target=\"" . $class->convert($target, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">" . $class->convert($name, "content") . "</a>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+#################################################################################
+# Image. #
+#################################################################################
+
+sub addimage{
+#################################################################################
+# addimage: Adds an image. #
+# #
+# Usage: #
+# #
+# $presmodule->addimage(image, options); #
+# #
+# image Specifies the location of the image. #
+# options Specifies the following options below (in any order). #
+# #
+# Style Specifies the CSS style to use. #
+# Description Specifies the description of the image. #
+# Width Specifies the width of the image. #
+# Height Specifies the height of the image. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($image, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $style = $options->{'Style'};
+ my $width = $options->{'Width'};
+ my $height = $options->{'Height'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$image){
+ die("The link to the image given is blank");
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ if (!$width){
+ $width = 0;
+ }
+
+ if (!$height){
+ $height = 0;
+ }
+
+ # Check if certain values are valid and return
+ # an error if they aren't.
+
+ my $width_validated = $width;
+ my $height_validated = $height;
+
+ $width_validated =~ tr/0-9//d;
+ $height_validated =~ tr/0-9//d;
+
+ if (!$width_validated){
+ die("The width value given is invalid.");
+ }
+
+ if (!$height_validated){
+ die("The height value given is invalid.");
+ }
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ # Add an image.
+
+ $tagdata = $tagdata . "<img src=\"" . $class->convert($image, "content") . "\"";
+
+ if ($style ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ if ($width ne 0){
+ $tagdata = $tagdata . " width=\"" . $class->convert($width, "content") . "\"";
+ }
+
+ if ($height ne 0){
+ $tagdata = $tagdata . " height=\"" . $class->convert($height, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+#################################################################################
+# Text. #
+#################################################################################
+
+sub addtext{
+#################################################################################
+# addtext: Adds some text. #
+# #
+# Usage: #
+# #
+# $presmodule->addtext(text, options); #
+# #
+# text Specifies the text to add. #
+# options Specifies the following options below (in any order). #
+# #
+# Style Specifies the CSS style to use. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($text, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $style = $options->{'Style'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$style){
+ $style = "";
+ }
+
+ if (!$text){
+ $text = "";
+ }
+
+ # Add some text.
+
+ if ($style ne ""){
+ $tagdata = $tagdata . "<span class=\"" . $class->convert($style, "content") . "\">" . $class->convert($text, "content") . "</span>";
+ } else {
+ $tagdata = $tagdata . $class->convert($text, "content");
+ }
+
+ # Append the tagdata to the pagedata.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub addboldtext{
+#################################################################################
+# addboldtext: Adds some bold text. #
+# #
+# Usage: #
+# #
+# $presmodule->addboldtext(text, options); #
+# #
+# text Specifies the text to add. #
+# options Specifies the following options below (in any order). #
+# #
+# Style Specifies the CSS style to use. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($text, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $style = $options->{'Style'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$text){
+ die("The text given was blank.");
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ # Add some bold text.
+
+ if ($style ne ""){
+ $tagdata = $tagdata . "<span class=\"\">" . $class->convert($text, "content") . "</span>";
+ } else {
+ $tagdata = $tagdata . "<b>" . $class->convert($text, "content") . "</b>";
+ }
+
+ # Append the tagdata to the pagedata.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub additalictext{
+#################################################################################
+# addboldtext: Adds some italic text. #
+# #
+# Usage: #
+# #
+# $presmodule->additalictext(text, options); #
+# #
+# text Specifies the text to add. #
+# options Specifies the following options below (in any order). #
+# #
+# Style Specifies the CSS style to use. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($text, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $style = $options->{'Style'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$text){
+ die("The text given was blank.");
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ # Add some italic text.
+
+ if ($style ne ""){
+ $tagdata = $tagdata . "<span class=\"\">" . $class->convert($text, "content") . "</span>";
+ } else {
+ $tagdata = $tagdata . "<i>" . $class->convert($text, "content") . "</i>";
+ }
+
+ # Append the tagdata to the pagedata.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub addlinebreak{
+#################################################################################
+# addlinebreak: Adds a line break specific to the output format. #
+# #
+# Usage: #
+# #
+# $presmodule->addlinebreak(); #
+#################################################################################
+
+ # Add a line break.
+
+ my $tagdata = "";
+
+ $tagdata = "<br>" . "\r\n";
+
+ # Append the tagdata to the pagedata.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub addhorizontalline{
+#################################################################################
+# addhorizontalline: Adds a horizontal line. #
+# #
+# Usage: #
+# #
+# $presmodule->addhorizontalline(); #
+#################################################################################
+
+ # Add a horizontal line.
+
+ my $tagdata = "";
+
+ $tagdata = "<hr>" . "\r\n";
+
+ # Append the tagdata to the pagedata.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+#################################################################################
+# Other. #
+#################################################################################
+
+sub startlist{
+#################################################################################
+# startlist: Start a list. #
+# #
+# Usage: #
+# #
+# $presmodule->startlist(); #
+#################################################################################
+
+ # Start a list.
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "<ul>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+ $tablevel++;
+
+}
+
+sub additem{
+#################################################################################
+# additem: Adds an item to the list. #
+# #
+# Usage: #
+# #
+# $presmodule->additem(text, options); #
+# #
+# text Specifies the text to use for the item. #
+# options Specifies the following options (in any order). #
+# #
+# Style Specifies the CSS style to use. #
+#################################################################################
+
+ # Get the options recieved.
+
+ my $class = shift;
+ my ($text, $options) = @_;
+
+ my $tagdata = "";
+ my $tabcount = $tablevel;
+
+ # Get certain values from the hash.
+
+ my $style = $options->{'Style'};
+
+ # Check if certain values are undefined and if they
+ # are then set them blank or to a default value.
+
+ if (!$text){
+ die("The text given was blank.");
+ }
+
+ if (!$style){
+ $style = "";
+ }
+
+ # Add an item to the list.
+
+ $tagdata = $tagdata . "<li ";
+
+ if ($style ne ""){
+ $tagdata = $tagdata . " class=\"" . $class->convert($style, "content") . "\"";
+ }
+
+ $tagdata = $tagdata . ">" . $class->convert($text, "content");
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+sub endlist{
+#################################################################################
+# endlist: End a list. #
+# #
+# Usage: #
+# #
+# $presmodule-endlist(); #
+#################################################################################
+
+ # End a list.
+
+ my $tagdata = "";
+ $tablevel = ($tablevel - 1);
+ my $tabcount = $tablevel;
+
+ while ($tabcount > 0){
+ $tagdata = $tagdata . "\t";
+ $tabcount = $tabcount - 1;
+ }
+
+ $tagdata = $tagdata . "</ul>" . "\r\n";
+
+ # Append the tag data to the page data.
+
+ $pagedata = $pagedata . $tagdata;
+
+}
+
+1;
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+
+<kiriwrite-language>
+ <about>
+ <name>English (British)</name>
+ <creator>Steve Brokenshire</creator>
+ <mailaddress>sbrokenshire(ao)xestia(dottie)co(dottie)uk</mailaddress>
+ </about>
+ <database>
+
+ <submenu>
+ <viewdatabases>View Databases</viewdatabases>
+ <adddatabase>Add Database</adddatabase>
+ </submenu>
+
+ <databasename>Database Name</databasename>
+ <databasedescription>Database Description</databasedescription>
+ <databasecategories>Database Categories</databasecategories>
+ <databasenotes>Database Notes</databasenotes>
+ <databasefilename>Database Filename</databasefilename>
+ <databaselistreturnlink>Return to the database list.</databaselistreturnlink>
+
+ <databaselist>Database List</databaselist>
+ <databaseoptions>Database Options</databaseoptions>
+ <nodatabasesavailable>There are no databases that can be used. To create a database click on the Add Database link.</nodatabasesavailable>
+ <databaseinvalidpermissions>Databases with invalid permissions</databaseinvalidpermissions>
+ <databaseinvalidpermissionstext>The following databases have invalid permissions set:</databaseinvalidpermissionstext>
+ <databaseerrors>Databases with errors</databaseerrors>
+ <databaseerrorstext>The following databases have errors:</databaseerrorstext>
+
+ <adddatabase>Add Database</adddatabase>
+ <adddatabaseautogenerate>Leave the filename blank to automatically generate a filename.</adddatabaseautogenerate>
+ <adddatabasenoextensions>Don't include any extensions as it will be done automatically.</adddatabasenoextensions>
+ <adddatabasecharacterlength>The filename cannot be any more than 32 characters long.</adddatabasecharacterlength>
+ <adddatabasecharacters>The filename should only contain letters, numbers and no spaces.</adddatabasecharacters>
+ <adddatabasebutton>Add Database</adddatabasebutton>
+ <clearvaluesbutton>Clear values</clearvaluesbutton>
+ <databaseadded>Database '%s' has been created.</databaseadded>
+
+ <editdatabasetitle>Edit Database</editdatabasetitle>
+ <editdatabase>Edit Database '%s'</editdatabase>
+ <editeddatabase>Edit Database</editeddatabase>
+ <editdatabasebutton>Edit Database</editdatabasebutton>
+ <databaseupdated>Database '%s' updated.</databaseupdated>
+
+ <deletedatabase>Database Deletion</deletedatabase>
+ <deletedatabasemessage>Are you sure you want to delete '%s'?</deletedatabasemessage>
+ <deletedatabasebutton>Yes, delete the database</deletedatabasebutton>
+ <deletedatabasereturn>No, return to the database list.</deletedatabasereturn>
+ <deleteddatabase>Database Deleted</deleteddatabase>
+ <deleteddatabasemessage>Database '%s' was deleted.</deleteddatabasemessage>
+
+ </database>
+ <pages>
+
+ <submenu>
+ <addpage>Add Page</addpage>
+ </submenu>
+
+ <database>Database</database>
+ <pagefilename>Page Filename</pagefilename>
+ <pagename>Page Name</pagename>
+ <pagedescription>Page Description</pagedescription>
+ <pagesection>Page Section</pagesection>
+ <pagetemplate>Page Template</pagetemplate>
+ <pagecontent>Page Content</pagecontent>
+ <pagesettings>Page Settings</pagesettings>
+ <lastmodified>Last Modified</lastmodified>
+
+ <returnpagelist>Return to the page list for the '%s' database.</returnpagelist>
+ <viewpagelist>View the page list for the '%s' database.</viewpagelist>
+
+ <databasepageerror>A database error occurred while getting the page information with the filename '%s': %s</databasepageerror>
+ <databasepagedoesnotexist>The page with the filename '%s' does not exist.</databasepagedoesnotexist>
+ <databasecopyfrompageerror>The page with the filename '%s' does not exist in the database that the page is to be copied from.</databasecopyfrompageerror>
+ <databasecopyfromdatabaseerror>A database error has occurred while copying the page with the filename '%s' from the old database: %s</databasecopyfromdatabaseerror>
+ <databasecopytodatabaseerror>A database error has occurred while copying the page with the filename '%s' to the new database: %s</databasecopytodatabaseerror>
+ <databasecopyfrompagenotexist>The page with the filename '%s' does not exist in the database that the page is to be copied from.</databasecopyfrompagenotexist>
+ <databasecopytopageexists>The page with the filename '%s' already exists in the database that the page is to be copied to.</databasecopytopageexists>
+ <databasemovefrompageerror>A database error has occurred while moving the page with the filename '%s' from the old database: %s</databasemovefrompageerror>
+ <databasemovetopageerror>A database error has occurred while moving the page with the filename '%s' to the new database: %s</databasemovetopageerror>
+ <databasemovefrompagenotexist>The page with the filename '%s' does not exist in the database that the page is to be moved from.</databasemovefrompagenotexist>
+ <databasemovetopageexists>The page with the filename '%s' already exists in the database that the page is to be moved to.</databasemovetopageexists>
+ <pagedoesnotexist>The page with the filename '%s' does not exist in the database that the page is to be moved from.</pagedoesnotexist>
+
+ <usenotemplate>Don't use a template</usenotemplate>
+ <keeptemplatefilename>Keep current template filename (%s)</keeptemplatefilename>
+
+ <usepageandsection>Use page name and section name.</usepageandsection>
+ <usepagename>Use the page name only.</usepagename>
+ <usesectionname>Use the section name only.</usesectionname>
+ <nopagesection>Don't use page name or section name.</nopagesection>
+
+ <notemplatedatabase>Template database does not exist. No template will be used.</notemplatedatabase>
+ <notemplatedatabasekeep>Template database does not exist. Existing template settings can be kept.</notemplatedatabasekeep>
+ <templatepermissionserror>Template database has invalid permissions set. No template will be used.</templatepermissionserror>
+ <templatepermissionserrorkeep>Template database has invalid permissions set. Existing template settings can be kept.</templatepermissionserrorkeep>
+ <templatedatabaseerror>A database error occurred while trying to get the list of templates: %s</templatedatabaseerror>
+ <templatedatabaseerrorkeep>A database error occurred while trying to get the list of templates: '%s'. Existing template settings can be kept.</templatedatabaseerrorkeep>
+ <notemplatesavailable>There are no templates in the template database. No template will be used.</notemplatesavailable>
+ <templatedatabasenotexistmultieditkeep>The template database does not exist. Existing template settings for selected pages kept.</templatedatabasenotexistmultieditkeep>
+ <templatedatabasepermissionsinvalidmultieditkeep>The template database has invalid permissions set. Existing template settings for selected pages kept.</templatedatabasepermissionsinvalidmultieditkeep>
+ <templatedatabaseerrormultieditkeep>A database error occurred while trying to get the list of templates: %s. Existing template settings for selected pages kept.</templatedatabaseerrormultieditkeep>
+
+ <viewingdatabase>Viewing Database</viewingdatabase>
+ <viewpages>View Pages</viewpages>
+ <databaseselecttitle>Database Selection</databaseselecttitle>
+ <nodatabaseselected>No database selected. Please select a database from the drop-down list below and then press the 'View' button to view the pages in the selected database.</nodatabaseselected>
+ <viewbutton>View</viewbutton>
+
+ <pagelist>Page list for '%s'</pagelist>
+ <nopagesindatabase>No pages exist in this database. To create a page for this database, click on Add Page link at the top of the page.</nopagesindatabase>
+ <deleteselectedbutton>Delete Selected</deleteselectedbutton>
+ <moveselectedbutton>Move Selected</moveselectedbutton>
+ <copyselectedbutton>Copy Selected</copyselectedbutton>
+ <editselectedbutton>Edit Selected</editselectedbutton>
+
+ <addpage>Add Page</addpage>
+ <addpagebutton>Add Page</addpagebutton>
+ <pageaddedmessage>The page called '%s' was added to the '%s' database successfully.</pageaddedmessage>
+
+ <editpagetitle>Edit Page</editpagetitle>
+ <editpage>Editing Page '%s'</editpage>
+ <editpagebutton>Edit Page</editpagebutton>
+ <editedpage>Page Edited</editedpage>
+ <editedpagemessage>The page '%s' has been edited.</editedpagemessage>
+
+ <deletepagetitle>Delete Page</deletepagetitle>
+ <deletepage>Delete page '%s'</deletepage>
+ <deletepagemessage>Are you sure you want to delete '%s' from the '%s' database?</deletepagemessage>
+ <deletepagebutton>Yes, delete the page</deletepagebutton>
+ <pagedeleted>Page Deleted</pagedeleted>
+ <pagedeletedmessage>The page named '%s' was deleted from the '%s' database.</pagedeletedmessage>
+
+ <deletemultiplepages>Delete selected pages</deletemultiplepages>
+ <deletemultiplemessage>Are you sure you want to delete the selected pages below from the '%s' database?</deletemultiplemessage>
+ <deletepagesbutton>Yes, delete the selected pages</deletepagesbutton>
+ <deletepagesreturnlink>No, return to the page list for the '%s' database.</deletepagesreturnlink>
+ <selectedpagesdeleted>Selected pages deleted</selectedpagesdeleted>
+ <selectedpagesdeletedmessage>The following pages were deleted from the '%s' database:</selectedpagesdeletedmessage>
+
+ <movepages>Move selected pages</movepages>
+ <movepagesmessage>Which database do you want to move the following pages from the '%s' database to?</movepagesmessage>
+ <movepagesto>Move pages to: </movepagesto>
+ <movepagesbutton>Move selected pages</movepagesbutton>
+ <movedpagesmessage>The following pages from the '%s' database were moved to the '%s' database:</movedpagesmessage>
+ <nopagesmoved>No pages were moved from the '%s' database to the '%s' database.</nopagesmoved>
+ <errormessages>The following errors/warnings have occurred while moving the pages:</errormessages>
+
+ <copypages>Copy selected pages</copypages>
+ <copypagesmessage>Which database do you want to copy the following pages from the '%s' database to?</copypagesmessage>
+ <copypagesto>Copy pages to:</copypagesto>
+ <copypagesbutton>Copy selected pages</copypagesbutton>
+ <copypagesresultmessage>The following pages from the '%s' database were copied to the '%s' database:</copypagesresultmessage>
+ <nopagescopied>No pages were copied from the '%s' database to the '%s' database.</nopagescopied>
+ <copypageswarnings>The following errors/warnings have occurred while copying the pages:</copypageswarnings>
+
+ <multiedit>Edit selected pages</multiedit>
+ <multieditmessage>The following pages from the '%s' database will be altered:</multieditmessage>
+ <multieditmessagevalues>Using the values below (click on the checkbox for each value to be edited on the selected pages):</multieditmessagevalues>
+ <editpagesbutton>Edit selected pages</editpagesbutton>
+ <nopagesedited>No pages were edited in the '%s' database.</nopagesedited>
+ <pagesedited>The selected pages in the '%s' database have been edited:</pagesedited>
+ <editedpageswarnings>The following errors/warnings occurred while editing the selected pages:</editedpageswarnings>
+
+ </pages>
+ <filter>
+
+ <submenu>
+ <showfilters>Show Filters</showfilters>
+ <addfilter>Add Filter</addfilter>
+ </submenu>
+
+ <priority>Priority</priority>
+ <findsetting>Find Setting</findsetting>
+ <replacesetting>Replace Setting</replacesetting>
+
+ <noprioritygiven>If no filter priority is specified, the filter priority will be set to 1.</noprioritygiven>
+ <returnfilterlist>Return to the filter list.</returnfilterlist>
+
+ <viewfilters>View Filters</viewfilters>
+ <nofiltersavailable>There are no filters available in the filters database. To add a filter, click on the Add Filter link.</nofiltersavailable>
+ <filterdatabasedoesnotexist>The filters database does not exist and will be created when a filter is added.</filterdatabasedoesnotexist>
+ <warningtitle>Warning: </warningtitle>
+ <blankfindfilters>One (or more) of your filters has a blank find filter and needs to be fixed.</blankfindfilters>
+ <blankfindsetting>Blank Find Setting</blankfindsetting>
+ <blankreplacesetting>Blank Replace Setting</blankreplacesetting>
+
+ <addfilter>Add Filter</addfilter>
+ <findfilter>Find...</findfilter>
+ <replacefilter>Replace with...</replacefilter>
+ <notes>Notes</notes>
+ <addfilterbutton>Add Filter</addfilterbutton>
+ <filteradded>Filter Added</filteradded>
+ <filteraddedmessage>The filter was added successfully to the filters list.</filteraddedmessage>
+
+ <editfilter>Edit Filter</editfilter>
+ <editfilterbutton>Edit Filter</editfilterbutton>
+ <editedfilter>Filter edited</editedfilter>
+ <editedfiltermessage>The selected filter was edited.</editedfiltermessage>
+
+ <deletefilter>Delete Filter</deletefilter>
+ <deletefiltermessage>Are you sure you want to delete the selected filter?</deletefiltermessage>
+ <deletefilterbutton>Yes, delete the selected filter.</deletefilterbutton>
+ <deletefilterreturn>No, return to the filter list.</deletefilterreturn>
+ <deletedfilter>Filter Deleted</deletedfilter>
+ <deletedfiltermessage>The selected filter was deleted from the filters list.</deletedfiltermessage>
+
+ </filter>
+ <template>
+
+ <submenu>
+ <showtemplates>Show Templates</showtemplates>
+ <addtemplate>Add Template</addtemplate>
+ </submenu>
+
+ <templatefilename>Template Filename</templatefilename>
+ <templatename>Template Name</templatename>
+ <templatedescription>Template Description</templatedescription>
+ <templatelayout>Template Layout</templatelayout>
+
+ <returntemplatelist>Return to the template list.</returntemplatelist>
+
+ <viewtemplates>View Templates</viewtemplates>
+ <templatedatabasedoesnotexist>The template database doesn't exist and will be created when a template is added.</templatedatabasedoesnotexist>
+ <notemplatesavailable>There are no templates in the template database. To add a template click on the Add Template link.</notemplatesavailable>
+
+ <addtemplate>Add Template</addtemplate>
+ <addtemplatebutton>Add Template</addtemplatebutton>
+ <addedtemplate>Template Added</addedtemplate>
+ <addedtemplatemessage>The template called '%s' was successfully created.</addedtemplatemessage>
+
+ <edittemplate>Edit Template</edittemplate>
+ <edittemplatebutton>Edit Template</edittemplatebutton>
+ <editedtemplate>Template Edited</editedtemplate>
+ <editedtemplatemessage>The selected template called '%s' was edited.</editedtemplatemessage>
+
+ <deletetemplate>Delete Template</deletetemplate>
+ <deletetemplatemessage>Are you sure you want to delete the template called '%s' (%s)?</deletetemplatemessage>
+ <deletetemplatebutton>Yes, delete the template.</deletetemplatebutton>
+ <deletetemplatereturntolist>No, return to the template list.</deletetemplatereturntolist>
+ <deletedtemplate>Template Deleted</deletedtemplate>
+ <deletedtemplatemessage>The selected template called '%s' was deleted.</deletedtemplatemessage>
+
+ </template>
+ <compile>
+
+ <submenu>
+ <listdatabases>List Databases</listdatabases>
+ <compileall>Compile All</compileall>
+ <cleanoutputdirectory>Clean Output Directory</cleanoutputdirectory>
+ </submenu>
+
+ <returncompilelist>Return to the compile database list.</returncompilelist>
+
+ <compilepages>Compile Pages</compilepages>
+ <nodatabasesavailable>There are no databases that can be used for compiling.</nodatabasesavailable>
+ <compileselectedbutton>Compile Selected</compileselectedbutton>
+
+ <compilealldatabases>Compile All Databases</compilealldatabases>
+ <compilealldatabasesmessage>Do you want to compile all of the databases in the database directory?</compilealldatabasesmessage>
+ <compilealldatabasesbutton>Compile All Databases</compilealldatabasesbutton>
+
+ <compileselecteddatabases>Compile Selected Databases</compileselecteddatabases>
+ <compileselecteddatabasesmessage>Do you want to compile the following databases?</compileselecteddatabasesmessage>
+ <compileselecteddatabasesbutton>Compile Selected Databases</compileselecteddatabasesbutton>
+
+ <compiledatabase>Compile Database</compiledatabase>
+ <compiledatabasemessage>Are you sure you want to compile the '%s' database?</compiledatabasemessage>
+ <compiledatabasebutton>Compile Database</compiledatabasebutton>
+
+ <informationprefix>[Information] </informationprefix>
+ <errorprefix>[Error] </errorprefix>
+ <warningprefix>[Warning] </warningprefix>
+
+ <compiledatabases>Compile Databases</compiledatabases>
+ <filterdatabasemissing>The filters database does not exist. No filters will be used.</filterdatabasemissing>
+ <filterdatabasepermissions>The filters database has invalid permissions set. No filters will be used.</filterdatabasepermissions>
+ <filterdatabaseerror>A filter database error has occurred: %s. No filters will be used.</filterdatabaseerror>
+ <findfilterblank>One (or more) of the find filters from the filters database is blank.</findfilterblank>
+ <finishfilterdatabase>Finished processing the filters database.</finishfilterdatabase>
+ <templatedatabasemissing>The templates database does not exist. Pages will be compiled without templates being used.</templatedatabasemissing>
+ <templatedatabasepermissions>The templates database has invalid permissions set. Pages will be compiled without templates being used.</templatedatabasepermissions>
+ <templatedatabaseerror>A database error occurred while trying to get the list of templates: %s</templatedatabaseerror>
+ <finishtemplatedatabase>Finished processing the templates database.</finishtemplatedatabase>
+ <databasefilenameinvalidcharacters>The database with the filename '%s' has invalid characters. Skipping this database...</databasefilenameinvalidcharacters>
+ <databasefilenametoolong>The database with the filename '%s' is too long. Skipping this database...</databasefilenametoolong>
+ <databasemissing>The database with the filename '%s' does not exist. Skipping this database...</databasemissing>
+ <databaseinvalidpermissions>The database with the filename '%s' has invalid permissions set. Skipping this database...</databaseinvalidpermissions>
+ <databaseerror>A database error has occurred on the database with the filename '%s': %s</databaseerror>
+ <compilingpages>Compiling pages in the '%s' database...</compilingpages>
+ <databasepageerror>A database error has occurred on the database with the filename '%s' while getting the list of pages: %s</databasepageerror>
+ <invalidpagefilename>The page '%s' has an invalid filename. Page skipped.</invalidpagefilename>
+ <templatefilemissing>The template with the filename '%s' for '%s' (%s) does not exist.</templatefilemissing>
+ <pageinvalidpermissions>The page with the filename '%s' has invalid permissions set. Page not written.</pageinvalidpermissions>
+ <pagenotwritten>An error occured while writing the page with the filename '%s': %s</pagenotwritten>
+ <compiledpageblankname> (%s) was compiled.</compiledpageblankname>
+ <compiledpage>'%s' (%s) was compiled.</compiledpage>
+ <databasefinish>Finished compiling pages in the '%s' database...</databasefinish>
+ <compileresults>%s pages compiled, %s errors, %s warnings.</compileresults>
+
+ <cleanoutputdirectory>Clean Output Directory</cleanoutputdirectory>
+ <cleanoutputdirectorymessage>Are you sure you want to clean the output directory?</cleanoutputdirectorymessage>
+ <cleanoutputdirectorybutton>Yes, clean output directory</cleanoutputdirectorybutton>
+ <somecontentnotremoved>Some of the contents of the directory were removed. However, not all of the files in the output directory were deleted due to invalid permissions.</somecontentnotremoved>
+ <contentremoved>The contents of the output directory have been removed.</contentremoved>
+
+ </compile>
+ <setting>
+ <submenu>
+ <viewsettings>View Settings</viewsettings>
+ <editsettings>Edit Settings</editsettings>
+ </submenu>
+
+ <viewsettings>View Settings</viewsettings>
+ <currentsettings>The current settings being used are the following:</currentsettings>
+ <directories>Directories</directories>
+ <databasedirectory>Database Directory</databasedirectory>
+ <outputdirectory>Output Directory</outputdirectory>
+ <imagesuripath>Images (URI path)</imagesuripath>
+ <date>Date</date>
+ <dateformat>Date Format</dateformat>
+ <language>Language</language>
+ <systemlanguage>System Language</systemlanguage>
+ <modules>Modules</modules>
+ <presentationmodule>Presentation Module</presentationmodule>
+ <databasemodule>Database Module</databasemodule>
+ <altersettings>To alter the current settings, select the Edit Settings option at the top of the page.</altersettings>
+
+ <editsettings>Edit Settings</editsettings>
+ <warning>Warning: </warning>
+ <warningmessage>Settings that have changed take effect after clicking on the 'Change Settings' button and viewing the confirmation message.</warningmessage>
+ <singleday>D - Show single digit day if day value is less than 10.</singleday>
+ <doubleday>DD - Show double digit day if day value is less than 10.</doubleday>
+ <singlemonth>M - Show single digit month if month value is less than 10.</singlemonth>
+ <doublemonth>MM - Show double digit month if month value is less than 10.</doublemonth>
+ <singleyear>Y - Show double digit year value.</singleyear>
+ <doubleyear>YY - Show four digit year value.</doubleyear>
+ <singlehour>h - Show single digit hour if hour value is less than 10.</singlehour>
+ <doublehour>hh - Show double digit hour if hour value is less than 10.</doublehour>
+ <singleminute>m - Show single digit minute if minute value is less than 10.</singleminute>
+ <doubleminute>mm - Show double digit minute if minute value is less than 10.</doubleminute>
+ <singlesecond>s - Show single digit second if second value is less than 10.</singlesecond>
+ <doublesecond>ss - Show double digit second if second value is less than 10.</doublesecond>
+ <othercharacters>Other Characters: / - < > ;</othercharacters>
+ <databaseserver>Database Server</databaseserver>
+ <databaseport>Database Port</databaseport>
+ <databaseprotocol>Database Protocol</databaseprotocol>
+ <databasename>Database Name</databasename>
+ <databaseusername>Database Username</databaseusername>
+ <databasepassword>Database Password</databasepassword>
+ <keepcurrentpassword>Keep the current password</keepcurrentpassword>
+ <tableprefix>Table Prefix</tableprefix>
+ <changesettingsbutton>Change Settings</changesettingsbutton>
+ <returnsettingslist>Return to the list of settings.</returnsettingslist>
+ <settingsedited>Settings Edited</settingsedited>
+ <settingseditedmessage>The page settings have been changed and will take effect on the next page load of Kiriwrite.</settingseditedmessage>
+
+ </setting>
+ <error>
+ <error>Error!</error>
+ <extendederror>The extended information about the error is:</extendederror>
+ <generic>An error has occurred but not an error that is known to Kiriwrite.</generic>
+ <blankfilename>The filename specified was blank.</blankfilename>
+ <blankvariable>A blank variable was specified.</blankvariable>
+ <fileexists>A filename specified already exists.</fileexists>
+ <internalerror>An internal error has occurred within Kiriwrite.</internalerror>
+ <invalidoption>An invalid option was given.</invalidoption>
+ <invalidaction>An invalid action was specified.</invalidaction>
+ <invalidfilename>The filename given contains invalid characters.</invalidfilename>
+ <invalidmode>An invalid mode was specified.</invalidmode>
+ <invalidutf8>A UTF-8 string is invalid.</invalidutf8>
+ <invalidvariable>An variable with invalid data has been found.</invalidvariable>
+ <variabletoolong>A variable given is too long.</variabletoolong>
+ <blankcompiletype>The compile type specified was blank.</blankcompiletype>
+ <blankdatabasepageadd>No database was specified when trying to add a page.</blankdatabasepageadd>
+ <blankdirectory>The directory name specified was blank.</blankdirectory>
+ <blankfindfilter>The find filter was blank.</blankfindfilter>
+ <blankdatetimeformat>The date and time format given is blank.</blankdatetimeformat>
+ <databaseconnectionerror>A database connection error has occurred.</databaseconnectionerror>
+ <databasecategoriestoolong>The database categories list is too long.</databasecategoriestoolong>
+ <databasecopysame>The database that the pages are being copied to is the same database that the pages are copied from.</databasecopysame>
+ <databasealreadyexists>A database with the filename given already exists.</databasealreadyexists>
+ <datadirectorymissing>The database directory is missing.</datadirectorymissing>
+ <datadirectoryinvalidpermissions>The database directory has invalid permission settings.</datadirectoryinvalidpermissions>
+ <databasedescriptiontoolong>The database description is too long.</databasedescriptiontoolong>
+ <databasefilenameinvalid>The database filename is invalid.</databasefilenameinvalid>
+ <databasefilenametoolong>The database filename is too long.</databasefilenametoolong>
+ <databaseerror>A database error has occurred.</databaseerror>
+ <databaseinvalidpermissions>The database has invalid permission settings.</databaseinvalidpermissions>
+ <databasenameinvalid>The database name contains invalid characters.</databasenameinvalid>
+ <databasenametoolong>The database name is too long.</databasenametoolong>
+ <databasenameblank>The database name is blank.</databasenameblank>
+ <databasemissingfile>The database file is missing.</databasemissingfile>
+ <databasemovemissingfile>The database that the pages are moving to is missing.</databasemovemissingfile>
+ <databasenorename>The database cannot be renamed due to invalid permissions set.</databasenorename>
+ <databasemovesame>The database that the pages are being moved to is the same database that the pages are moving from.</databasemovesame>
+ <dbmoduleblank>The database module name given is blank.</dbmoduleblank>
+ <dbmoduleinvalid>The database module name given is invalid.</dbmoduleinvalid>
+ <dbdirectoryblank>The database directory name given was blank.</dbdirectoryblank>
+ <dbdirectoryinvalid>The database directory name given was invalid.</dbdirectoryinvalid>
+ <dbmodulemissing>The database module with the filename given is missing.</dbmodulemissing>
+ <filtersdatabasenotcreated>The filters database was not created because of the invalid permissions set.</filtersdatabasenotcreated>
+ <filtersdbdatabaseerror>A database error has occurred while using the filters database.</filtersdbdatabaseerror>
+ <filtersdbpermissions>The filters database has invalid permission settings.</filtersdbpermissions>
+ <filtersdbmissing>The filters database is missing.</filtersdbmissing>
+ <filteridblank>The filter identification number given is blank.</filteridblank>
+ <filterdoesnotexist>The filter with the identification number given does not exist.</filterdoesnotexist>
+ <filteridinvalid>The filter identification number given is invalid.</filteridinvalid>
+ <filteridtoolong>The filter identification number given is too long.</filteridtoolong>
+ <findfiltertoolong>The find filter given is too long.</findfiltertoolong>
+ <filterpriorityinvalid>The filter priority number given is invalid.</filterpriorityinvalid>
+ <filterpriorityinvalidchars>The filter priority given contains invalid characters.</filterpriorityinvalidchars>
+ <filterprioritytoolong>The filter priority given is too long.</filterprioritytoolong>
+ <invalidcompiletype>The compile type given is invalid.</invalidcompiletype>
+ <invalidpagenumber>The page number specified is invalid.</invalidpagenumber>
+ <nopagesselected>No pages were selected.</nopagesselected>
+ <invaliddirectory>The directory name specified was invalid.</invaliddirectory>
+ <invaliddatetimeformat>The date and time format given is invalid.</invaliddatetimeformat>
+ <invalidlanguagefilename>An invalid language filename was given.</invalidlanguagefilename>
+ <languagefilenamemissing>The language filename given does not exist.</languagefilenamemissing>
+ <moduleblank>The module name given was blank.</moduleblank>
+ <moduleinvalid>The module name given was invalid.</moduleinvalid>
+ <newcopydatabasedatabaseerror>A database error has occurred in the database that the selected pages are being copied to.</newcopydatabasedatabaseerror>
+ <newcopydatabasedoesnotexist>The database that the selected pages are being copied to does not exist.</newcopydatabasedoesnotexist>
+ <newcopydatabasefileinvalidpermissions>The database that the selected pages are being copied to has invalid permissions set.</newcopydatabasefileinvalidpermissions>
+ <newmovedatabasedatabaseerror>A database error has occurred in the database that the selected pages are being moved to.</newmovedatabasedatabaseerror>
+ <newmovedatabasedoesnotexist>The database that the selected pages are moving to does not exist.</newmovedatabasedoesnotexist>
+ <newmovedatabasefileinvalidpermissions>The database that the selected pages are moving to has invalid permissions set.</newmovedatabasefileinvalidpermissions>
+ <nodatabasesavailable>No databases are available for compiling.</nodatabasesavailable>
+ <nodatabaseselected>No databases were selected for compiling.</nodatabaseselected>
+ <noeditvaluesselected>No values will be changed on the selected pages as no values for changing were selected.</noeditvaluesselected>
+ <oldcopydatabasedatabaseerror>A database error has occurred in the database that the selected pages are being copied from.</oldcopydatabasedatabaseerror>
+ <oldcopydatabasedoesnotexist>The database that the selected pages are being copied from does not exist.</oldcopydatabasedoesnotexist>
+ <oldcopydatabasefileinvalidpermissions>The database that the selected pages are being copied from has invalid permissions set.</oldcopydatabasefileinvalidpermissions>
+ <oldmovedatabasedatabaseerror>A database error has occurred in the database that the selected pages are being moved from.</oldmovedatabasedatabaseerror>
+ <oldmovedatabasedoesnotexist>The database that the selected pages are moving from does not exist.</oldmovedatabasedoesnotexist>
+ <oldmovedatabasefileinvalidpermissions>The database that the selected pages are moving from has invalid permissions set.</oldmovedatabasefileinvalidpermissions>
+ <outputdirectoryblank>The output directory name given was blank.</outputdirectoryblank>
+ <outputdirectoryinvalid>The output directory name given was invalid.</outputdirectoryinvalid>
+ <outputdirectorymissing>The output directory is missing</outputdirectorymissing>
+ <outputdirectoryinvalidpermissions>The output directory has invalid permissions set.</outputdirectoryinvalidpermissions>
+ <presmoduleblank>The presentation module name given is blank.</presmoduleblank>
+ <presmoduleinvalid>The presentation module name given is invalid.</presmoduleinvalid>
+ <presmodulemissing>The presentation module with the filename given is missing.</presmodulemissing>
+ <pagefilenamedoesnotexist>The page with the filename given does not exist.</pagefilenamedoesnotexist>
+ <pagefilenameexists>The page filename given already exists</pagefilenameexists>
+ <pagefilenameinvalid>The page filename given is invalid.</pagefilenameinvalid>
+ <pagefilenametoolong>The page filename given is too long.</pagefilenametoolong>
+ <pagefilenameblank>The page filename given is blank.</pagefilenameblank>
+ <pagetitletoolong>The page title given is too long.</pagetitletoolong>
+ <pagedescriptiontoolong>The page description given is too long.</pagedescriptiontoolong>
+ <pagesectiontoolong>The page section given is too long.</pagesectiontoolong>
+ <pagedatabasefilenametoolong>The page database filename given is too long.</pagedatabasefilenametoolong>
+ <pagesettingstoolong>The page settings given is too long.</pagesettingstoolong>
+ <pagesettingsinvalid>The page settings given are invalid.</pagesettingsinvalid>
+ <pagetemplatefilenametoolong>The page template filename given was too long.</pagetemplatefilenametoolong>
+ <replacefiltertoolong>The replace filter given is too long</replacefiltertoolong>
+ <servernameinvalid>The database server name given is invalid.</servernameinvalid>
+ <servernametoolong>The database server name given is too long.</servernametoolong>
+ <serverdatabasenameinvalid>The server database name given is invalid.</serverdatabasenameinvalid>
+ <serverdatabasenametoolong>The server database name given is too long.</serverdatabasenametoolong>
+ <serverdatabaseusernameinvalid>The server database username given is invalid.</serverdatabaseusernameinvalid>
+ <serverdatabaseusernametoolong>The server database username given is too long.</serverdatabaseusernametoolong>
+ <serverdatabasepasswordtoolong>The server database password given is too long.</serverdatabasepasswordtoolong>
+ <serverdatabasetableprefixinvalid>The server database table prefix given is invalid.</serverdatabasetableprefixinvalid>
+ <serverdatabasetableprefixtoolong>The server database table prefix given is too long.</serverdatabasetableprefixtoolong>
+ <serverportnumberinvalid>The database port number given is invalid.</serverportnumberinvalid>
+ <serverportnumberinvalidcharacters>The database port number given contains characters other than numbers.</serverportnumberinvalidcharacters>
+ <serverportnumbertoolong>The database port number given is too long.</serverportnumbertoolong>
+ <serverprotocolnametoolong>The database server protocol name given is too long.</serverprotocolnametoolong>
+ <serverprotocolinvalid>An invalid database server protocol was specified.</serverprotocolinvalid>
+ <templatenameblank>The template name given is blank.</templatenameblank>
+ <templatefilenameexists>A template with the given filename already exists.</templatefilenameexists>
+ <templatefilenameinvalid>The template filename given is invalid.</templatefilenameinvalid>
+ <templatedatabaseerror>A database error has occurred while using the template database.</templatedatabaseerror>
+ <templatedatabaseinvalidpermissions>The template database has invalid permissions.</templatedatabaseinvalidpermissions>
+ <templatedatabaseinvalidformat>The template database is in a invalid format.</templatedatabaseinvalidformat>
+ <templatedirectoryblank>The template directory name given was blank.</templatedirectoryblank>
+ <templatedirectoryinvalid>The template directory name given was invalid.</templatedirectoryinvalid>
+ <templatedatabasenotcreated>The template database was not created because of the invalid permissions set.</templatedatabasenotcreated>
+ <templatefilenametoolong>The template filename given is too long</templatefilenametoolong>
+ <templatenametoolong>The template name given is too long</templatenametoolong>
+ <templatedescriptiontoolong>The template description given is too long</templatedescriptiontoolong>
+ <templatedatabasemissing>The template database is missing.</templatedatabasemissing>
+ <templatedoesnotexist>The template filename given does not exist in the templates database.</templatedoesnotexist>
+ <templatefilenameblank>The template filename given was blank.</templatefilenameblank>
+
+ </error>
+ <options>
+ <edit>Edit</edit>
+ <delete>Delete</delete>
+ <compile>Compile</compile>
+ </options>
+ <blank>
+ <noname>No Name</noname>
+ <nodescription>No Description</nodescription>
+ <blankdatabasename>Blank Database Name</blankdatabasename>
+ </blank>
+ <common>
+ <alter>Alter</alter>
+ <setting>Setting</setting>
+ <value>Value</value>
+ <restorecurrent>Restore current settings</restorecurrent>
+ <clearvalues>Clear values</clearvalues>
+ <selectnone>Select None</selectnone>
+ <options>Options</options>
+
+ <tags>Kiriwrite Tags:</tags>
+ <pagecontent><kiriwrite:pagecontent> - Specifies the page content.</pagecontent>
+ <pagetitle><kiriwrite:pagetitle> - Specifies the page title (and page section depending on page settings).</pagetitle>
+ <pagename><kiriwrite:pagename> - Specifies the page name.</pagename>
+ <pagedescription><kiriwrite:pagedescription> - Specifies the page description.</pagedescription>
+ <pagesection><kiriwrite:pagesection> - Specifies the page section.</pagesection>
+ <pageautosection><kiriwrite:autosection> - Automatic page section name.</pageautosection>
+ <pageautotitle><kiriwrite:autotitle> - Automatic page title (and page section depending on page settings).</pageautotitle>
+
+ </common>
+ <menu>
+ <viewdatabases>View Databases</viewdatabases>
+ <viewpages>View Pages</viewpages>
+ <viewfilters>View Filters</viewfilters>
+ <viewtemplates>View Templates</viewtemplates>
+ <compilepages>Compile Pages</compilepages>
+ <viewsettings>View Settings</viewsettings>
+ </menu>
+</kiriwrite-language>
+++ /dev/null
-<?xml version="1.0"?>
-
-<kiriwrite-language>
- <about>
- <name>English UK</name>
- <systemname>English UK</systemname>
- </about>
- <strings>
- </strings>
-</kiriwrite-language>