diff --git a/ext/user/main.php b/ext/user/main.php index 9b2028a8..4ef5f244 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -212,8 +212,8 @@ class UserPage implements Extension { if(strlen($name) < 1) { $event->veto("Username must be at least 1 character"); } - else if(!preg_match('/^[a-zA-Z0-9-_ ]+$/', $name)) { - $event->veto("Username contains invalid characters. Allowed characters are letters, numbers, dash, underscore, and space"); + else if(!preg_match('/^[a-zA-Z0-9-_]+$/', $name)) { + $event->veto("Username contains invalid characters. Allowed characters are letters, numbers, dash, and underscore"); } else if($database->db->GetRow("SELECT * FROM users WHERE name = ?", array($name))) { $event->veto("That username is already taken"); diff --git a/themes/minimal/layout.class.php b/themes/minimal/layout.class.php new file mode 100644 index 00000000..4a62a41d --- /dev/null +++ b/themes/minimal/layout.class.php @@ -0,0 +1,82 @@ +get_string('theme', 'default'); + $data_href = get_base_href(); + $contact_link = $config->get_string('contact_link'); + $version = "Shimmie-".VERSION; + + $header_html = ""; + foreach($page->headers as $line) { + $header_html .= "\t\t$line\n"; + } + + $left_block_html = ""; + $main_block_html = ""; + + foreach($page->blocks as $block) { + switch($block->section) { + case "left": + $left_block_html .= $this->block_to_html($block, true, "left"); + break; + case "main": + $main_block_html .= $this->block_to_html($block, false, "main"); + break; + default: + print "

error: {$block->header} using an unknown section ({$block->section})"; + break; + } + } + + $debug = get_debug_info(); + + $contact = empty($contact_link) ? "" : "
Contact"; + + if(empty($page->subheading)) { + $subheading = ""; + } + else { + $subheading = "

{$page->subheading}
"; + } + + print << + + + {$page->title} + + +$header_html + + + + + +
$main_block_html
+ + + + +EOD; + } + + function block_to_html($block, $hidable=false, $salt="") { + $h = $block->header; + $b = $block->body; + $html = ""; + $i = str_replace(' ', '_', $h) . $salt; + if(!is_null($b)) $html .= "
$b
\n"; + return $html; + } +} +?> diff --git a/themes/minimal/page.class.php b/themes/minimal/page.class.php new file mode 100644 index 00000000..07d2fc45 --- /dev/null +++ b/themes/minimal/page.class.php @@ -0,0 +1,6 @@ + diff --git a/themes/minimal/script.js b/themes/minimal/script.js new file mode 100644 index 00000000..3b26466e --- /dev/null +++ b/themes/minimal/script.js @@ -0,0 +1,136 @@ +var defaultTexts = new Array(); + +window.onload = function(e) { + var sections=get_sections(); + for(var i=0;iINPUT[type="submit"] {width: 100%;} +TD>INPUT[type="text"] {width: 100%;} +TD>INPUT[type="password"] {width: 100%;} +TD>SELECT {width: 100%;} + +#footer { + clear: both; + padding-top: 8px; + font-size: 0.7em; + text-align: center; +} + +*[onclick] {cursor: pointer;} +IMG {border: none;} +FORM {margin: 0px;} +A {text-decoration: none;} +A:hover {text-decoration: underline;} + +BLOCKQUOTE { + border: 1px solid black; + padding: 8px; + background: #DDD; +} + +UL { + text-align: left; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* the navigation bar, and all its blocks * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#nav { + width: 150px; + float: left; + text-align: center; + font-size: 0.9em; +} +#nav TABLE { + width: 150px; +} +#nav TD { + vertical-align: middle; +} +#nav INPUT { + width: 100%; + padding: 0px; +} +#nav SELECT { + width: 100%; + padding: 0px; +} + +#comments P { + text-align: left; + width: 150px; + max-width: 150px; + overflow: hidden; +} + +.more:after { + content: " >>>"; +} + +.tag_count:before { + content: "("; +} +.tag_count:after { + content: ")"; +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* the main part of each page * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#body { + margin-left: 160px; + text-align: center; + height: 1%; +} +#body TABLE { + width: 90%; + margin: auto; +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* specific page types * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#pagelist { + margin-top: 32px; +} + +#tagmap A { + padding: 8px 4px 8px 4px; +} + +.comment { + text-align: left; +} + +.setupblock { + border: 1px solid #AAA; + padding: 8px; + margin: 16px; + width: 350px; +} + +.helpable { + border-bottom: 1px dashed gray; +} + +.ok { + background: #AFA; +} +.bad { + background: #FAA; +} + + diff --git a/themes/minimal/themelet.class.php b/themes/minimal/themelet.class.php new file mode 100644 index 00000000..93e3c5f9 --- /dev/null +++ b/themes/minimal/themelet.class.php @@ -0,0 +1,89 @@ +set_title($title); + $page->set_heading($title); + $page->add_block(new NavBlock()); + $page->add_block(new Block("Error", $message)); + } + + + /** + * A specific, common error message + */ + public function display_permission_denied($page) { + header("HTTP/1.0 403 Permission Denied"); + $this->display_error($page, "Permission Denied", "You do not have permission to access this page"); + } + + + /** + * Generic thumbnail code; returns HTML rather than adding + * a block since thumbs tend to go inside blocks... + */ + public function build_thumb_html($image, $query=null) { + global $config; + $i_id = int_escape($image->id); + $h_view_link = make_link("post/view/$i_id", $query); + $h_tip = html_escape($image->get_tooltip()); + $h_thumb_link = $image->get_thumb_link(); + $tsize = get_thumbnail_size($image->width, $image->height); + return "$h_tip"; + } + + + /** + * Add a generic paginator + */ + public function display_paginator($page, $base, $query, $page_number, $total_pages) { + if($total_pages == 0) $total_pages = 1; + $body = $this->build_paginator($page_number, $total_pages, $base, $query); + $page->add_block(new Block(null, $body, "main", 90)); + } + + private function gen_page_link($base_url, $query, $page, $name) { + $link = make_link("$base_url/$page", $query); + return "$name"; + } + + private function gen_page_link_block($base_url, $query, $page, $current_page, $name) { + $paginator = ""; + if($page == $current_page) $paginator .= ""; + $paginator .= $this->gen_page_link($base_url, $query, $page, $name); + if($page == $current_page) $paginator .= ""; + return $paginator; + } + + private function build_paginator($current_page, $total_pages, $base_url, $query) { + $next = $current_page + 1; + $prev = $current_page - 1; + $rand = rand(1, $total_pages); + + $at_start = ($current_page <= 1 || $total_pages <= 1); + $at_end = ($current_page >= $total_pages); + + $first_html = $at_start ? "First" : $this->gen_page_link($base_url, $query, 1, "First"); + $prev_html = $at_start ? "Prev" : $this->gen_page_link($base_url, $query, $prev, "Prev"); + $random_html = $this->gen_page_link($base_url, $query, $rand, "Random"); + $next_html = $at_end ? "Next" : $this->gen_page_link($base_url, $query, $next, "Next"); + $last_html = $at_end ? "Last" : $this->gen_page_link($base_url, $query, $total_pages, "Last"); + + $start = $current_page-5 > 1 ? $current_page-5 : 1; + $end = $start+10 < $total_pages ? $start+10 : $total_pages; + + $pages = array(); + foreach(range($start, $end) as $i) { + $pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, $i); + } + $pages_html = implode(" | ", $pages); + + return "

$first_html | $prev_html | $random_html | $next_html | $last_html". + "
<< $pages_html >>

"; + } +} +?>