Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
831 florian 1
<?php
2
 
3
// Make sure that this script is loaded from the admin interface.
4
if(!defined("PHORUM_ADMIN")) return;
5
 
6
// Save settings in case this script is run after posting
7
// the settings form.
8
if(count($_POST))
9
{
10
    // Create the settings array for this module.
11
    $PHORUM["mod_example_settings"] = array(
12
        "displaytext"  => $_POST["displaytext"],
13
        "displaycount" => $_POST["displaycount"],
14
    );
15
 
16
    // Force the displaycount to be an integer value.
17
    settype($PHORUM["mod_example_settings"]["displaycount"], "int");
18
 
19
    if(! phorum_db_update_settings(array("mod_example_settings"=>$PHORUM["mod_example_settings"]))) {
20
        $error="Database error while updating settings.";
21
    } else {
22
        echo "Settings Updated<br />";
23
    }
24
}
25
 
26
// Apply default values for the settings.
27
if (!isset($PHORUM["mod_example_settings"]["displaytext"]))
28
    $PHORUM["mod_example_settings"]["displaytext"] = "";
29
if (!isset($PHORUM["mod_example_settings"]["displaycount"]))
30
    $PHORUM["mod_example_settings"]["displaycount"] = 1;
31
 
32
// We build the settings form by using the PhorumInputForm object. When
33
// creating your own settings screen, you'll only have to change the
34
// "mod" hidden parameter to the name of your own module.
35
include_once "./include/admin/PhorumInputForm.php";
36
$frm = new PhorumInputForm ("", "post", "Save");
37
$frm->hidden("module", "modsettings");
38
$frm->hidden("mod", "example_settings");
39
 
40
// Here we display an error in case one was set by saving
41
// the settings before.
42
if (!empty($error)) {
43
    echo "$error<br />";
44
}
45
 
46
// This adds a break line to your form, with a description on it.
47
// You can use this to separate your form into multiple sections.
48
$frm->addbreak("Edit settings for the example_settings module");
49
 
50
// This adds a text message to your form. You can use this to
51
// explain things to the user.
52
$frm->addmessage("This is the settings screen for the example_settings module. This module is only written for demonstrating the use of a settings screen for you own modules. The module itself will display a configurable text for a configurable number of times on screen.");
53
 
54
// This adds a row with a form field for entering the display text.
55
$frm->addrow("Text to display (default: Hello, world!)", $frm->text_box('displaytext', $PHORUM["mod_example_settings"]["displaytext"], 50));
56
 
57
// This adds another row with a form field for entering the display count.
58
$frm->addrow("Number of times to display", $frm->text_box('displaycount', $PHORUM["mod_example_settings"]["displaycount"], 5));
59
 
60
// We are done building the settings screen.
61
// By calling show(), the screen will be displayed.
62
$frm->show();
63
 
64
?>