From d1d2f525b9315d8690965dfcdcf320963bf3caf9 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 9 Oct 2009 13:11:42 +0100 Subject: [PATCH] add old tips extension for the record --- contrib/oldtips/.main.php.swp | Bin 0 -> 12288 bytes contrib/oldtips/main.php | 29 +++++++++++++++++++++++++++++ contrib/oldtips/main.php~ | 30 ++++++++++++++++++++++++++++++ contrib/oldtips/test.php | 23 +++++++++++++++++++++++ contrib/oldtips/theme.php | 9 +++++++++ 5 files changed, 91 insertions(+) create mode 100644 contrib/oldtips/.main.php.swp create mode 100644 contrib/oldtips/main.php create mode 100644 contrib/oldtips/main.php~ create mode 100644 contrib/oldtips/test.php create mode 100644 contrib/oldtips/theme.php diff --git a/contrib/oldtips/.main.php.swp b/contrib/oldtips/.main.php.swp new file mode 100644 index 0000000000000000000000000000000000000000..43f45cf6336544e02e0174b12ced98f4c1df1073 GIT binary patch literal 12288 zcmeI2zi-n(6vwX!h6qZlB1WV~$l#=;E=2-ViVGD#R8&ya0t-da*}m8(>^sYMZVIS$ z?mxl+5(5(x{{|~U{0$7iz&j_E5EaV80(w@yIs5#*yZ1il43S?r|7i6dT%Ma}cuX^v z?C;)P{WLf_HN}`orAb}?nBzIOyyRm{c>85Np^x8rF2!7ZrG%Z+W#Vry_>oq&l%a2B zVf>s+HCLp?_*uz81c<;`0+sD|uS~Lw3m592`nl#=I5qQd>@YGA0U|&IhyW2F0z`la z5CJ0a{}8an1lz-Oj*L<|GioP(Ye$#V5CI}U1c(3;AOb{y2oM1xKm>>Y5g-EpAORjT zwtIrH$w>?z-~S){|Nn;X|G%O>qu!%lp<>hq%16zjI;dl)k0%-XfZ9iGp}MH!s4qC@ zJJeg$8`Nvm9;%1BggT9yK~1CF`adv^?<3 z13!(H*cQrm4|N0uS0d{MJdS%|rlY4`%Y^N#ZiESk-I-R26+5=43oEtqny!4g=X#n4 zMz{t_3}92(s#vLKX+A(xeZQ!}Oh(YJROE((Rzq7QvskLc8%EZK7i<`*i?-3SSee}o zY$|fm4Pt4Ej6dt)!d_pOIk)xlUMrJIwCf-m^*P2-x8^Y~OB_&g6%Spe{lq0Tv>Eh? zog&k*@S0nyc^+CWr_n_26b(fwl3por;Rs#+mYVg^_(yvSi@W o(_xuDEDc1Mb7Mt${nx_!z&Y>p90zU;*TXcK-|4WWWmjJR6H`YlD*ylh literal 0 HcmV?d00001 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)); + } +} +?>