From 7391dcf0b601210f7645df7cbc539b3f9829c234 Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 26 Jun 2012 19:58:35 +0100 Subject: [PATCH] configuarable oekaki size, and more consistent creation --- ext/oekaki/theme.php | 48 +++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/ext/oekaki/theme.php b/ext/oekaki/theme.php index 50f73034..ac74df8e 100644 --- a/ext/oekaki/theme.php +++ b/ext/oekaki/theme.php @@ -3,27 +3,21 @@ // FIXME: Move default canvas size to config file; changeable in board config // While we're here, add maximum and minimum image sizes in config // Maybe allow the resolution limiter extension to have a say in this -$defOekW = 400; // Common default for oekaki boards: 300x300 -$defOekH = 400; + class OekakiTheme extends Themelet { public function display_page() { - global $config, $page, $defOekW, $defOekH; + global $config, $page; $base_href = get_base_href(); $http_base = make_http($base_href); - if (isset($_POST['oekW']) and isset($_POST['oekH'])){ - $oekW = $_POST['oekW']; - $oekH = $_POST['oekH']; - if(!ctype_digit($oekW) or !ctype_digit($oekH)){ - $oekW = $defOekW; - $oekH = $defOekH; - } - } else{ - $oekW = $defOekW; - $oekH = $defOekH; + $oekW = $config->get_int("oekaki_width", 400); + $oekH = $config->get_int("oekaki_height", 400); + if(isset($_POST['oekW']) && isset($_POST['oekH'])) { + $oekW = int_escape($_POST['oekW']); + $oekH = int_escape($_POST['oekH']); } - + $html = " @@ -31,7 +25,7 @@ class OekakiTheme extends Themelet { - JAVA NOT INSTALLED >:( + JAVA NOT INSTALLED :( "; @@ -61,20 +55,24 @@ class OekakiTheme extends Themelet { } public function display_block() { - global $page, $defOekW, $defOekH; + global $config, $page; //FIXME: input field alignment could be done more elegantly, without inline styling //FIXME: autocomplete='off' seems to be an invalid HTML tag - $page->add_block(new Block(null, + + $oekW = $config->get_int("oekaki_width", 400); + $oekH = $config->get_int("oekaki_height", 400); + if(isset($_POST['oekW']) && isset($_POST['oekH'])) { + $oekW = int_escape($_POST['oekW']); + $oekH = int_escape($_POST['oekH']); + } + + $page->add_block(new Block("Oekaki", " - Oekaki -
-
- - x - - -
+ ". + "x". + "". + "
" , "left", 21)); // upload is 20