PApp
view release on metacpan or search on metacpan
our $logfile = undef;
our $prefs = new PApp::Prefs \""; # the global preferences
our $curprefs = new PApp::Prefs *location; # the current application preferences
our ($st_reload_p, $st_replacepref, $st_deletepref, $st_newuserid, $st_insertstate,
$_config, $st_newstateids, $st_fetchstate, $st_eventcount, $event_count);
%preferences = ( # system default preferences
'' => [qw(
papp_locale
papp_cookie
)],
);
# flush translation table caches when they are re-written
PApp::Event::on papp_i18n_flush => sub {
PApp::I18n::flush_cache;
};
our $restart_flag;
if ($restart_flag) {
die "FATAL ERROR: PerlFreshRestart is buggy\n";
PApp::Util::_exit(0);
} else {
$restart_flag = 1;
}
our $save_prefs_cb = create_callback {
&save_prefs if $userid;
} name => "papp_save_prefs";
our $start_session_cb = create_callback {
&start_session;
} name => "papp_start_session";
sub SURL_PUSH ($$){ ( "\x00\x01", undef, @_ ) }
sub SURL_UNSHIFT ($$){ ( "\x00\x02", undef, @_ ) }
sub SURL_POP ($) { ( "\x00\x81", @_ ) }
sub SURL_SHIFT ($) { ( "\x00\x82", @_ ) }
#sub SURL_EXEC ($) { SURL_PUSH("/papp_execonce" => $_[0]) }
sub SURL_EXEC_IMMED ($) { "\x00\x91", \$_[0] }
sub SURL_EXEC ($) { $_[0] }
sub SURL_SAVE_PREFS () { $save_prefs_cb }
sub SURL_SET_LOCALE ($) { ( SURL_SAVE_PREFS, "/papp_locale" => $_[0] ) }
sub SURL_START_SESSION() { SURL_EXEC_IMMED ($start_session_cb) }
sub SURL_SUFFIX ($) { ("\x00\x41", @_) }
sub SURL_STYLE ($) { ("\x00\x42", @_) }
sub _SURL_STYLE_URL () { 1 }
sub _SURL_STYLE_GET () { 2 }
sub _SURL_STYLE_STATIC() { 3 }
sub SURL_STYLE_URL () { SURL_STYLE(_SURL_STYLE_URL ) }
sub SURL_STYLE_GET () { SURL_STYLE(_SURL_STYLE_GET ) }
sub SURL_STYLE_STATIC () { SURL_STYLE(_SURL_STYLE_STATIC ) }
sub CHARSET (){ "utf-8" } # the charset used internally by PApp
# we might be slow, but we are rarely being called ;)
sub __($) {
$translator
? $translator->get_table($langs)->gettext($_[0])
: $_[0]
}
sub N_($) { $_[0] }
# constant
our $xmlnspapp = "http://www.plan9.de/xmlns/papp";
=head1 Global Variables
Some global variables are free to use and even free to change (yes, we
still are about speed, not abstraction). In addition to these variables,
the globs C<*state>, C<*S> and C<*A> (and in future versions C<*L>)
are reserved. This means that you cannot define a scalar, sub, hash,
filehandle or whatsoever with these names.
=over 4
=item $request [read-only]
The Apache request object (L<Apache>), the same as returned by C<< Apache->request >>.
=item %state [read-write, persistent]
A system-global hash that can be used for almost any purpose, such as
saving (global) preferences values. All keys with prefix C<papp> are
reserved for use by this module. Everything else is yours.
=item %P [read-write, input only]
Contains the parameters from forms submitted via GET or POST (C<see
parse_multipart_form>, however). Everything in this hash is insecure by
nature and must be sanitised before use.
Normally, the values stored in C<%P> are plain strings (in UTF-8,
though). However, it is possible to submit the same field multiple times,
in which case the value stored in C<$P{field}> is a reference to an array
with all strings, i.e. if you want to evaluate a form field that might be
submitted multiple times (e.g. checkboxes or multi-select elements) you
must use something like this:
my @values = ref $P{field} ? @{$P{field}} : $P{field};
=item %temporary [not exported]
Is empty at the beginning of a request and will be cleared at request end.
=item $userid [read-only]
The current userid. User-Id's are automatically assigned, you are
encouraged to use them for your own user-databases, but you must not trust
them. C<$userid> is zero in case no userid has been assigned yet. In this
case you can force a userid by calling the function C<getuid>, which
allocated one if necessary,
=item $sessionid [read-only]
A unique number identifying the current session (not page). You could use
this for transactions or similar purposes. This variable might or might
not be zero indicating that no session has been allocated yet (similar to
C<$userid> == 0).
=item $curprefs, $prefs [L<PApp::Prefs>]
( run in 3.370 seconds using v1.01-cache-2.11-cpan-364913b4093 )