diff --git a/contrib/oldtips/.main.php.swp b/contrib/oldtips/.main.php.swp new file mode 100644 index 00000000..43f45cf6 Binary files /dev/null and b/contrib/oldtips/.main.php.swp differ diff --git a/contrib/oldtips/main.php b/contrib/oldtips/main.php new file mode 100644 index 00000000..c963cf68 --- /dev/null +++ b/contrib/oldtips/main.php @@ -0,0 +1,29 @@ + + * License: GPLv2 + * Description: Show a random line of text in the subheader space + * Documentation: + * Formatting is done with bbcode + */ + +class Tips extends SimpleExtension { + public function onPostListBuilding($event) { + global $config, $page; + if(strlen($config->get_string("tips_text")) > 0) { + $tips = $config->get_string("tips_text"); + $tips = preg_replace("/\n+/", "\n", $tips); + $lines = explode("\n", $tips); + $line = $lines[array_rand($lines)]; + $this->theme->display_tip(format_text($line)); + } + } + + public function onSetupBuilding($event) { + $sb = new SetupBlock("Tips"); + $sb->add_longtext_option("tips_text"); + $event->panel->add_block($sb); + } +} +?> diff --git a/contrib/oldtips/main.php~ b/contrib/oldtips/main.php~ new file mode 100644 index 00000000..24db4dea --- /dev/null +++ b/contrib/oldtips/main.php~ @@ -0,0 +1,30 @@ + + * License: GPLv2 + * Description: Show a random line of text in the subheader space + * Documentation: + * Formatting is done with bbcode + */ + +class Tips extends SimpleExtension { + public function onPostListBuilding($event) { + global $config, $page; + if(strlen($config->get_string("tips_text")) > 0) { + $icon = null; + $tips = $config->get_string("tips_text"); + $tips = preg_replace("/\n+/", "\n", $tips); + $lines = explode("\n", $tips); + $line = $lines[array_rand($lines)]; + $this->theme->display_tip(format_text($line)); + } + } + + public function onSetupBuilding($event) { + $sb = new SetupBlock("Tips"); + $sb->add_longtext_option("tips_text"); + $event->panel->add_block($sb); + } +} +?> diff --git a/contrib/oldtips/test.php b/contrib/oldtips/test.php new file mode 100644 index 00000000..bdc2125d --- /dev/null +++ b/contrib/oldtips/test.php @@ -0,0 +1,23 @@ +log_in_as_admin(); + + $this->get_page("setup"); + $this->setField("_config_tips_text", "alert:kittens"); + $this->click("Save Settings"); + + $this->get_page("post/list"); + $this->assertText("kittens"); + + $this->get_page("setup"); + $this->setField("_config_news_text", ""); + $this->click("Save Settings"); + + $this->get_page("post/list"); + $this->assertNoText("kittens"); + + $this->log_out(); + } +} +?> diff --git a/contrib/oldtips/theme.php b/contrib/oldtips/theme.php new file mode 100644 index 00000000..1aa0bb38 --- /dev/null +++ b/contrib/oldtips/theme.php @@ -0,0 +1,9 @@ +add_block(new Block(null, $text, "main", 5)); + } +} +?>