diff --git a/config.php b/config.php index 95314e6..e2d790d 100644 --- a/config.php +++ b/config.php @@ -60,7 +60,14 @@ // // The CSS file to load to style the wiki, relative to BASE_URI -define('CSS_FILE', 'index.css'); +define('CSS_FILE', 'styles/original.css'); + +// Templates +// +// The template file to load, should match css, relative to BASE_URI + +define('TEMPLATE', 'templates/original.php'); + // -------------------- // File upload settings @@ -163,4 +170,28 @@ define('W2_SESSION_NAME', 'W2'); -?> + +// ----------------------------- +// Locale and encoding settings +// ----------------------------- + +// W2_CHARSET +// +// Value for meta charset. + +define('W2_CHARSET', 'UTF-8'); + +// W2_LOCALE +// +// Name for locale. + +define('W2_LOCALE', 'en'); + +// ----------------------------- +// Navigation menu +// ----------------------------- +// +// Optional navigation menu and its content file + +define('NAVMENU', true); +define('NAVMENU_FILE', PAGES_PATH . '/Menu.txt'); diff --git a/index.css b/index.css deleted file mode 100644 index 4443f61..0000000 --- a/index.css +++ /dev/null @@ -1,160 +0,0 @@ -/* - * W2 - * - * Copyright (C) 2007-2011 Steven Frank - * - * Code may be re-used as long as the above copyright notice is retained. - * See README.txt for full details. - * - * Written with Coda: - * - */ - -* { - font-family: Helvetica, sans-serif; - font-size: 13px; - margin: 0; - padding: 0; -} - -blockquote { - background-color: #f0f8f0; - margin: 0px 0px 12px 20px; - padding-top: 4px 10px 4px 10px; -} - -form { - display: inline; -} - -li { - line-height: 1.5em; -} - -h1 { - font-size: 20px; - font-weight: bold; - margin-bottom: 8px; -} - -h2 { - font-size: 16px; - font-weight: bold; - margin-bottom: 8px; -} - -h3 { - font-size: 13px; - font-weight: bold; - margin-bottom: 8px; -} - -hr { - border-top: 1px solid #cccccc; - border-bottom: 0; - border-left: 0; - border-right: 0; - margin-top: 12px; - margin-bottom: 12px; -} - -ul { - padding-left: 12px; - margin-left: 12px; - margin-bottom: 12px; - list-style-position: inside; -} - -ol { - margin-left: 12px; - margin-bottom: 12px; - padding-left: 12px; - list-style-position: inside; -} - -p { - margin: 12px 12px 12px 12px; -} - -pre { - font-family: Menlo, Courier, monospace; - font-size: 11px; - margin-left: 12px; - margin-bottom: 12px; - - /* stroke each browser so that they wrap lines in the pre tag */ - white-space: pre-wrap; /* css-3 */ - white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ - white-space: -pre-wrap; /* Opera 4-6 */ - white-space: -o-pre-wrap; /* Opera 7 */ - word-wrap: break-word; /* Internet Explorer 5.5+ */ -} - -code { - font-family: Menlo, Courier, monospace; - font-size: 11px; -} - -table { - border-collapse: collapse; -} - -table, td { - padding: 2px; -} - -textarea { - font-family: Menlo, Courier, monospace; - font-size: 11px; - width: 99%; - background-color: #ffffee; -} - -.main { - padding: 8px; -} - -.note { - background-color: #ffffcc; - padding: 4px; - margin: 0 8px 8px 8px; - color: #666644; - border: solid 1px #666644; -} - -.titlebar { - background-color: #222222; - background: -webkit-gradient(linear, left top, left bottom, from(#555555), to(#000000)); - color: #ffffff; - font-size: 18px; - font-weight: bold; - padding: 4px 4px 4px 12px; -} - -.titledate { - font-size: 10px; - color: #999999; -} - -.toolbar { - background-color: #777777; - background: -webkit-gradient(linear, left top, left bottom, from(#666666), to(#444444)); - font-size: 12px; - padding: 4px 4px 4px 12px; -} - -a.tool { - font-size: 11px; - margin-right: 8px; - color: #eeeeee; -} - -input.tool { - font-size: 11px; - color: #000000; -} - -img { - max-width: 100%; - height: auto; -} diff --git a/index.php b/index.php index 0737af9..fa246c9 100644 --- a/index.php +++ b/index.php @@ -26,6 +26,37 @@ include_once "config.php"; +// Localize functions + +include_once 'locales/' . W2_LOCALE . '.php'; + +/** + * Get translated word + * + * String $label Key for locale word + * String $alt_word Alternative word + * return String + */ +function __( $label, $alt_word = null ){ + global $w2_word_set; + + if( empty($w2_word_set[$label]) ) { + return is_null($alt_word) ? $label : $alt_word; + } + return htmlspecialchars($w2_word_set[$label], ENT_QUOTES); +} + +/** + * Echo translated word + * + * String $label Key for locale word + * String $alt_word Alternative word + */ +function _e( $label, $alt_word = null ){ + echo __($label, $alt_word); +} + + ini_set('session.gc_maxlifetime', W2_SESSION_LIFETIME); session_set_cookie_params(W2_SESSION_LIFETIME); @@ -64,17 +95,18 @@ else { print "\n"; - print "\n"; + print '' . "\n"; print "\n"; + print '' . "\n"; print ""; print "\n"; print "\n"; - print "Log In\n"; + print '' . __('Log In') . '' . "\n"; print "\n"; print "
"; print "\n"; - print "
"; + print ''; print ""; exit; } @@ -82,30 +114,70 @@ // Support functions -function printToolbar() +function printHome() { global $upage, $page, $action; + print "". __(DEFAULT_PAGE) . ""; +} - print "
"; - print "Edit "; - print "New "; +function printAll() +{ + global $upage, $page, $action; + print "". __('All') .""; +} - if ( !DISABLE_UPLOADS ) - print "Upload "; +function printRecent() +{ + global $upage, $page, $action; + print "". __('Recent') .""; +} - print "All "; - print "Recent "; - print "". DEFAULT_PAGE . ""; - +function printPassword() +{ + global $upage, $page, $action; if ( REQUIRE_PASSWORD ) - print 'Exit'; + print ''. __('Exit') .''; +} + +function printEdit() +{ + global $upage, $page, $action; + print "". __('Edit') .""; +} + +function printNew() +{ + global $upage, $page, $action; + print ''. __('New') .''; +} + +function printUpload() +{ + global $upage, $page, $action; + if ( !DISABLE_UPLOADS ) + print '' . __('Upload') .''; +} +function printSearch() +{ + global $upage, $page, $action; print "
\n"; - print "
\n"; - - print "
\n"; + print "\n"; } +function printNavmenu() +{ + global $upage, $page, $action; + if ( NAVMENU && $action == "view" ) + { + if ( file_exists(NAVMENU_FILE) ) + { + $menutext = file_get_contents(NAVMENU_FILE); + $menuhtml = toHTML($menutext); + print "
\n$menuhtml\n
\n"; + } + } +} function descLengthSort($val_1, $val_2) { @@ -225,6 +297,7 @@ function file_put_contents($n, $d) } else { + $text = ''; if ( $action != "save" && $action != "all_name" && $action != "all_date" && $action != "upload" && $action != "new" && $action != "logout" && $action != "uploaded" && $action != "search" && $action != "view" ) { $action = "edit"; @@ -239,16 +312,16 @@ function file_put_contents($n, $d) if ( $action == "edit" ) $html .= "\n"; else - $html .= "

Title:

\n"; + $html .= '

' . __('Title') . ':

' . "\n"; if ( $action == "new" ) $text = ""; - $html .= "

\n"; + $html .= "

\n"; $html .= "

"; - $html .= "\n"; - $html .= "

\n"; - $html .= "\n"; + $html .= ''."\n"; + $html .= ''."\n"; + $html .= "

\n"; } else if ( $action == "logout" ) { @@ -260,15 +333,15 @@ function file_put_contents($n, $d) { if ( DISABLE_UPLOADS ) { - $html = "

Image uploading has been disabled on this installation.

"; + $html = '

' . __('Image uploading has been disabled on this installation.') . '

'; } else { $html = "

\n"; $html .= ""; $html .= "\n"; - $html .= "\n"; - $html .= "\n"; + $html .= ''."\n"; + $html .= ''."\n"; $html .= "

\n"; } } @@ -293,12 +366,12 @@ function file_put_contents($n, $d) } else { - $html = "

Upload error

\n"; + $html = '

' . __('Upload error') . '

'. "\n"; } error_reporting($errLevel); } else { - $html = "

Upload error: invalid file type

\n"; + $html = '

' . __('Upload error: invalid file type') . '

' . "\n"; } } @@ -306,14 +379,14 @@ function file_put_contents($n, $d) } else if ( $action == "save" ) { - $newText = $_REQUEST['newText']; + $newText = stripslashes($_REQUEST['newText']); $errLevel = error_reporting(0); $success = file_put_contents($filename, $newText); error_reporting($errLevel); - if ( $success ) - $html = "

Saved

\n"; + if ( $success ) + $html = "

" . __('Saved') . "

\n"; else $html = "

Error saving changes! Make sure your web server has write access to " . PAGES_PATH . "

\n"; @@ -372,27 +445,26 @@ function file_put_contents($n, $d) if ( $file{0} == "." ) continue; - $afile = preg_replace("/(.*?)\.txt/", "\\1", $file); - $efile = preg_replace("/(.*?)\.txt/", "edit", urlencode($file)); - - array_push($filelist, "$afile$efile"); - - if ( $color == "#ffffff" ) - $color = "#f4f4f4"; - else - $color = "#ffffff"; + array_push($filelist, $file); } closedir($dir); natcasesort($filelist); - - $html = ""; + $html = "
"; - for ($i = 0; $i < count($filelist); $i++) + foreach ($filelist as $file) { - $html .= $filelist[$i]; + $afile = preg_replace("/(.*?)\.txt/", "\\1", $file); + $efile = preg_replace("/(.*?)\.txt/", "" . __('Edit') . '', urlencode($file)); + + $html .= ""; + + if ( $color == "#ffffff" ) + $color = "#f4f4f4"; + else + $color = "#ffffff"; } $html .= "
$afile$efile
\n"; @@ -417,8 +489,11 @@ function file_put_contents($n, $d) foreach ($filelist as $key => $value) { - $html .= "$key" . date(TITLE_DATE_NO_TIME, $value) . "\n"; - + $date_format = __('date_format', TITLE_DATE); + $html .= "$key" + . date( $date_format, $value) + . "\n"; + if ( $color == "#ffffff" ) $color = "#f4f4f4"; else @@ -430,7 +505,7 @@ function file_put_contents($n, $d) { $matches = 0; $q = $_REQUEST['q']; - $html = "

Search: $q

\n