add old tips extension for the record
This commit is contained in:
parent
0d3e7e0acc
commit
d1d2f525b9
BIN
contrib/oldtips/.main.php.swp
Normal file
BIN
contrib/oldtips/.main.php.swp
Normal file
Binary file not shown.
29
contrib/oldtips/main.php
Normal file
29
contrib/oldtips/main.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Random Tip
|
||||
* Author: Shish <webmaster@shishnet.org>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
?>
|
30
contrib/oldtips/main.php~
Normal file
30
contrib/oldtips/main.php~
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Random Tip
|
||||
* Author: Shish <webmaster@shishnet.org>
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
?>
|
23
contrib/oldtips/test.php
Normal file
23
contrib/oldtips/test.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
class TipsTest extends SCoreWebTestCase {
|
||||
function testTips() {
|
||||
$this->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();
|
||||
}
|
||||
}
|
||||
?>
|
9
contrib/oldtips/theme.php
Normal file
9
contrib/oldtips/theme.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
class TipsTheme extends Themelet {
|
||||
public function display_tip($text) {
|
||||
global $page;
|
||||
$page->add_block(new Block(null, $text, "main", 5));
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user