2007-07-19 12:13:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class SetupTheme extends Themelet {
|
2007-07-28 20:30:01 +00:00
|
|
|
/*
|
|
|
|
* Display a set of setup option blocks
|
|
|
|
*
|
|
|
|
* $panel = the container of the blocks
|
|
|
|
* $panel->blocks the blocks to be displayed, unsorted
|
|
|
|
*
|
|
|
|
* It's recommented that the theme sort the blocks before doing anything
|
|
|
|
* else, using: usort($panel->blocks, "blockcmp");
|
|
|
|
*
|
|
|
|
* The page should wrap all the options in a form which links to setup_save
|
|
|
|
*/
|
2009-01-04 20:04:55 +00:00
|
|
|
public function display_page(Page $page, SetupPanel $panel) {
|
2010-05-28 13:26:46 +00:00
|
|
|
global $user;
|
|
|
|
|
2007-07-19 12:13:46 +00:00
|
|
|
|
|
|
|
usort($panel->blocks, "blockcmp");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try and keep the two columns even; count the line breaks in
|
|
|
|
* each an calculate where a block would work best
|
|
|
|
*/
|
2012-02-12 09:51:25 +00:00
|
|
|
$setupblock_html = "";
|
2007-07-19 12:13:46 +00:00
|
|
|
foreach($panel->blocks as $block) {
|
2012-02-12 09:51:25 +00:00
|
|
|
$html = $this->sb_to_html($block);
|
|
|
|
$setupblock_html .= $this->sb_to_html($block);
|
2007-07-19 12:13:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$table = "
|
2010-09-22 11:56:19 +00:00
|
|
|
".make_form(make_link("setup/save"))."
|
2012-02-12 09:51:25 +00:00
|
|
|
<div class='setupblocks'>$setupblock_html</div>
|
|
|
|
<input type='submit' value='Save Settings'>
|
2010-09-22 11:56:19 +00:00
|
|
|
</form>
|
2007-07-19 12:13:46 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
$page->set_title("Shimmie Setup");
|
|
|
|
$page->set_heading("Shimmie Setup");
|
|
|
|
$page->add_block(new Block("Navigation", $this->build_navigation(), "left", 0));
|
|
|
|
$page->add_block(new Block("Setup", $table));
|
|
|
|
}
|
|
|
|
|
2009-01-04 19:54:16 +00:00
|
|
|
public function display_advanced(Page $page, $options) {
|
2010-05-28 13:26:46 +00:00
|
|
|
global $user;
|
|
|
|
|
2008-04-06 21:03:13 +00:00
|
|
|
$rows = "";
|
2009-01-17 04:24:43 +00:00
|
|
|
$n = 0;
|
2009-11-12 09:13:21 +00:00
|
|
|
ksort($options);
|
2008-04-06 21:03:13 +00:00
|
|
|
foreach($options as $name => $value) {
|
|
|
|
$h_value = html_escape($value);
|
|
|
|
$len = strlen($h_value);
|
2009-01-17 04:24:43 +00:00
|
|
|
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
|
|
|
|
2008-04-06 21:03:13 +00:00
|
|
|
$box = "";
|
2009-01-17 04:24:43 +00:00
|
|
|
if(strpos($value, "\n") > 0) {
|
|
|
|
$box .= "<textarea cols='50' rows='4' name='_config_$name'>$h_value</textarea>";
|
2008-04-06 21:03:13 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-01-17 04:24:43 +00:00
|
|
|
$box .= "<input type='text' name='_config_$name' value='$h_value'>";
|
2008-04-06 21:03:13 +00:00
|
|
|
}
|
|
|
|
$box .= "<input type='hidden' name='_type_$name' value='string'>";
|
2009-01-17 04:24:43 +00:00
|
|
|
$rows .= "<tr class='$oe'><td>$name</td><td>$box</td></tr>";
|
2008-04-06 21:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$table = "
|
2011-08-13 01:40:51 +00:00
|
|
|
<script type='text/javascript'>
|
2009-07-07 12:42:34 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
$(\"#settings\").tablesorter();
|
|
|
|
});
|
|
|
|
</script>
|
2010-09-22 11:56:19 +00:00
|
|
|
".make_form(make_link("setup/save"))."
|
|
|
|
<table id='settings' class='zebra'>
|
|
|
|
<thead><tr><th width='25%'>Name</th><th>Value</th></tr></thead>
|
|
|
|
<tbody>$rows</tbody>
|
|
|
|
<tfoot><tr><td colspan='2'><input type='submit' value='Save Settings'></td></tr></tfoot>
|
|
|
|
</table>
|
|
|
|
</form>
|
2008-04-06 21:03:13 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
$page->set_title("Shimmie Setup");
|
|
|
|
$page->set_heading("Shimmie Setup");
|
|
|
|
$page->add_block(new Block("Navigation", $this->build_navigation(), "left", 0));
|
|
|
|
$page->add_block(new Block("Setup", $table));
|
|
|
|
}
|
|
|
|
|
2007-08-23 11:14:03 +00:00
|
|
|
protected function build_navigation() {
|
2007-07-19 12:13:46 +00:00
|
|
|
return "
|
2007-07-26 13:19:39 +00:00
|
|
|
<a href='".make_link()."'>Index</a>
|
2009-07-07 15:08:00 +00:00
|
|
|
<br><a href='http://redmine.shishnet.org/wiki/shimmie2/Settings'>Help</a>
|
2008-04-06 21:03:13 +00:00
|
|
|
<br><a href='".make_link("setup/advanced")."'>Advanced</a>
|
2007-07-19 12:13:46 +00:00
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2009-01-04 19:54:16 +00:00
|
|
|
protected function sb_to_html(SetupBlock $block) {
|
2007-07-19 12:13:46 +00:00
|
|
|
return "<div class='setupblock'><b>{$block->header}</b><br>{$block->body}</div>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|