示例#1
0
<?php

require '../../includes/prepend.inc.php';
// First of all, let's override the way QForm stores state information.
// We will use the session-based FormState Handler, instead of the standard/default
// formstate handler.  Also, let's encrypt the formstate index by defining
// an encryption key.
//
// NOTE: This preference can be set, globally, by updating the QForm class
// which is located at /includes/qform/QForm.inc
QForm::$FormStateHandler = 'QSessionFormStateHandler';
QForm::$EncryptionKey = '\\rSome.Random!Key\\0';
// Everything else below should be the exact same as our original Hello, World! example
class ExampleForm extends QForm
{
    // Local declarations of our Qcontrols
    protected $lblMessage;
    protected $btnButton;
    // Initialize our Controls during the Form Creation process
    protected function Form_Create()
    {
        // Define the Label
        $this->lblMessage = new QLabel($this);
        $this->lblMessage->Text = 'Click the button to change my message.';
        // Define the Button
        $this->btnButton = new QButton($this);
        $this->btnButton->Text = 'Click Me!';
        // Add a Click event handler to the button
        $this->btnButton->AddAction(new QClickEvent(), new QServerAction('btnButton_Click'));
    }
    // The "btnButton_Click" Event handler
示例#2
0
            }
        }
    }
    //////////////////////////////////////////////
    // Setup Internationalization and Localization (if applicable)
    // Note, this is where you would implement code to do Language Setting discovery, as well, for example:
    // * Checking against $_GET['language_code']
    // * checking against session (example provided below)
    // * Checking the URL
    // * etc.
    // TODO: options to do this are left to the developer
    //////////////////////////////////////////////
    if (isset($_SESSION)) {
        if (array_key_exists('country_code', $_SESSION)) {
            QApplication::$CountryCode = $_SESSION['country_code'];
        }
        if (array_key_exists('language_code', $_SESSION)) {
            QApplication::$LanguageCode = $_SESSION['language_code'];
        }
    }
    // Initialize I18n if QApplication::$LanguageCode is set
    if (QApplication::$LanguageCode) {
        QI18n::Initialize();
    } else {
        // QApplication::$CountryCode = 'us';
        // QApplication::$LanguageCode = 'en';
        // QI18n::Initialize();
    }
    QForm::$FormStateHandler = 'QFileFormStateHandler';
    QForm::$EncryptionKey = 'gogogadgetQcodoAPI';
}