App-ZofCMS

 view release on metacpan or  search on metacpan

lib/App/ZofCMS/Plugin/CRUD.pm  view on Meta::CPAN

by hand, but so far I haven't found a flexible solution that doesn't
drown the user of the plugin in settings options.

In addition, the plugin needs an option to add a variable amount of files,
all stored in a single database field, which in turn would allow updating
the file field during record editing.

Lastly, the plugin currently doesn't support
selects, checkboxes, or radio boxes in the Create/Update form.

=head1 A NOTE ON FORM INPUT ERROR CHECKING

This plugin only checks for whether or not a mandatory field is
present when creating/updating records. If you need more advanced error
checking, see L<App::ZofCMS::Plugin::FormChecker> that can (read "should")
work together with this plugin (run C<FormChecker> first).

=head1 REPOSITORY

Fork this module on GitHub:
L<https://github.com/zoffixznet/App-ZofCMS>

lib/App/ZofCMS/Plugin/GetRemotePageTitle.pm  view on Meta::CPAN


B<Optional>. Takes an L<LWP::UserAgent> object as a value; this object will be used for
fetching titles from the remote pages. B<Defaults to:>

    LWP::UserAgent->new(
        agent    => "Opera 9.5",
        timeout  => 30,
        max_size => 2000,
    ),

=head1 PLUGIN'S OUTPUT

    # uri argument set to a string
    <tmpl_if name='plug_remote_page_title_error'>
        <p class="error">Got error: <tmpl_var escape='html' name='plug_remote_page_title_error'></p>
    <tmpl_else>
        <p>Title: <tmpl_var escape='html' name='plug_remote_page_title'></p>
    </tmpl_if>


    # uri argument set to an arrayref

lib/App/ZofCMS/Plugin/GoogleCalculator.pm  view on Meta::CPAN

    }

B<Optional>. When C<from_query> argument is set to a false value, specifies the expression
to calculate. Takes either a literal expression as a string or a subref as a value.
When set to a subref, subref will be executed and its return value will be assigned
to C<expr> as if it was already there (note, C<undef>s will cause the plugin to
stop further processing). The sub's C<@_> will contain the following (in that order):
ZofCMS Template hashref, query parameters hashref and L<App::ZofCMS::Config> object.
B<Defaults to:> C<undef>

=head1 PLUGIN OUTPUT

    <tmpl_if name='plug_google_calculator_error'>
        <p class="error">Got error: <tmpl_var escape='html' name='plug_google_calculator_error'></p>
    <tmpl_else>
        <p>Result: <tmpl_var escape='html' name='plug_google_calculator'></p>
    </tmpl_if>

=head2 C<plug_google_calculator>

    <p>Result: <tmpl_var escape='html' name='plug_google_calculator'></p>

lib/App/ZofCMS/Plugin/GooglePageRank.pm  view on Meta::CPAN

B<Optional>. Specifies the first-level key in ZofCMS Template hashref into which to store
the result. Must point to an C<undef> or a hashref. B<Defaults to:> C<t>

=head3 C<key>

    key => 'plug_google_page_rank',

B<Optional>. Specifies the second-level key inside C<cell> first-level key into which
to put the results. B<Defaults to:> C<plug_google_page_rank>

=head1 OUTPUT

Depending on whether the C<uri> argument was set to a string (or not set at all) or an
arrayref the output will be either a string indicating page's rank or an arrayref of
hashrefs - enabling you to use a simple C<< <tmpl_loop> >>, each of the hashrefs will contain two keys: C<rank> and C<uri> - the rank of
the page referenced by that URI.

If there was an error while obtaining the rank (i.e. request timeout) the rank will
be shown as string C<'N/A'>.

=head2 EXAMPLE DUMP 1

lib/App/ZofCMS/Plugin/GoogleTime.pm  view on Meta::CPAN

    },

B<Optional>. Takes an L<LWP::UserAgent> object as a value; this object will be used for
accessing Google. B<Defaults to:>

    LWP::UserAgent->new(
        agent    => "Opera 9.5",
        timeout  => 30,
    ),

=head1 PLUGIN'S OUTPUT

    # location argument set to a string
    <tmpl_if name='plug_google_time_error'>
        <p class="error">Got error: <tmpl_var escape='html' name='plug_google_time_error'></p>
    <tmpl_else>
        <p>Time: <tmpl_var escape='html' name='plug_google_time'></p>
    </tmpl_if>


    # location argument set to an arrayref

lib/App/ZofCMS/Plugin/HTMLMailer.pm  view on Meta::CPAN

gives you an ability to attach files to your emails.
Takes an arrayref, an arrayref of arrayrefs, or a subref as a value. If an arrayref is
specified, plugin will create a single-item arrayref with it (so it'll be nested); if an
arrayref of arrayrefs is specified, each of its arrayrefs will be interpreted as a
list of arguments to pass to C<attach> method. If a subref is specified, its return
value will be assigned to the C<attach> key and its C<@_> array will contain:
C<$t>, C<$q>, C<$config> (in that order) where C<$t> is ZofCMS Template
hashref, C<$q> is the query parameter hashref and C<$config> is the
L<App::ZofCMS::Config> object. B<Default:> not specified

=head1 OUTPUT

This plugin doesn't produce any output and doesn't set any keys.

=head1 A WARNING ABOUT ERRORS

This plugin doesn't have any error handling. The behaviour is completely
undefined in cases of: invalid email addresses, improper or
insufficient C<mime_lite_params> values, no C<from> set, etc. For example,
on my system, not specifying any C<mime_lite_params> makes it look
like plugin is not running at all. If things go awry: copy the plugin's

lib/App/ZofCMS/Plugin/InstalledModuleChecker.pm  view on Meta::CPAN

            Foo::Bar::Baz
            Carp
        /,
    ],

B<Mandatory>. Takes an arrayref as a value.
Can be specified in either ZofCMS Template or Main Config File; if set in
both, the value in ZofCMS Template takes precedence. Each element of the arrayref
must be a module name that you wish to check for "installedness".

=head1 OUTPUT

    <ul>
        <tmpl_loop name='plug_installed_module_checker'>
        <li>
            <tmpl_var escape='html' name='info'>
        </li>
        </tmpl_loop>
    </ul>

Plugin will set C<< $t->{t}{plug_installed_module_checker} >> (where C<$t> is ZofCMS Template

lib/App/ZofCMS/Plugin/LinksToSpecs/HTML.pm  view on Meta::CPAN

        'u'
        => q|http://www.w3.org/TR/html401/present/graphics.html#edef-U|,

        'iframe'
        => q|http://www.w3.org/TR/html401/present/frames.html#edef-IFRAME|,

        'del'
        => q|http://www.w3.org/TR/html401/struct/text.html#edef-del|,

        'input'
        => q|http://www.w3.org/TR/html401/interact/forms.html#edef-INPUT|,

        'menu'
        => q|http://www.w3.org/TR/html401/struct/lists.html#edef-MENU|,

        'form'
        => q|http://www.w3.org/TR/html401/interact/forms.html#edef-FORM|,

        'button'
        => q|http://www.w3.org/TR/html401/interact/forms.html#edef-BUTTON|,

lib/App/ZofCMS/Plugin/RandomBashOrgQuote.pm  view on Meta::CPAN


=head1 TO RUN THE PLUGIN

    plugins => [
        qw/RandomBashOrgQuote/
    ],

Unlike many other plugins, this plugin does not have any configuration options and will
run if it's included in the list of plugins to run.

=head1 OUTPUT

    <pre><tmpl_var escape='html' name='plug_random_bash_org_quote'></pre>

Plugin will set C<< $t->{t}{plug_random_bash_org_quote} >> to the fetched random quote
or to an error message if an error occured; in case of an error the message will be prefixed
with C<Error:> (in case you wanna mingle with that).

=head1 REPOSITORY

Fork this module on GitHub:

lib/App/ZofCMS/Plugin/UserLogin/ChangePassword.pm  view on Meta::CPAN

B<Defaults to:> C<sub { $_[0]{d}{user}{login} }> (my common way of storing C<$user_ref> from
UserLogin plugin)

=head3 C<key>

    plug_user_login_change_password => sub {
        key     => 'change_pass_form',
    },

B<Optional>. Specifies the name of the key inside C<{t}> special key into which
the plugin will put the password change form (see PLUGIN'S HTML AND OUTPUT section for
details).
B<Defaults to:> C<change_pass_form>

=head3 C<min>

    plug_user_login_change_password => sub {
        min     => 4,
    },

B<Optional>. Takes a positive intereger or zero as a value. Specifies

lib/App/ZofCMS/Plugin/UserLogin/ChangePassword.pm  view on Meta::CPAN

        submit_button => q|<input type="submit" class="input_submit"|
            . q| name="plug_user_login_change_password_submit"|
            . q| value="Change password">|,
    },

B<Optional>. Takes a string of HTML code as a value. Specifies the
code for the submit button of the form; feel free to add any extra
code you might require as well. B<Defaults to:>
C<< <input type="submit" class="input_submit"  name="plug_user_login_change_password_submit" value="Change password"> >>

=head1 PLUGIN'S HTML AND OUTPUT

The plugin uses key in C<{t}> special key that is specified via C<key> plugin's configuration
argument (defaults to C<change_pass_form>). That key will contain either the HTML
form for password changing or the message that password was successfully changed.

If an error occured (such as mismatching passwords), plugin will set
C<< $t->{t}{plug_user_login_change_password_error} >> to a true value (where C<$t> is
ZofCMS Template hashref). If password was successfully changed, plugin will set
C<< $t->{t}{plug_user_login_change_password_ok} >> to a true value (where C<$t> is
ZofCMS Template hashref). You do not have to use these, as they are set only if you have

lib/App/ZofCMS/Plugin/UserLogin/ForgotPassword.pm  view on Meta::CPAN

    if ( has_value($q->{$conf->{q_code}}) ) {
        $self->process_q_code;
    }
    elsif ( has_value($q->{pulfp_ask_link}) ) {
        $self->process_ask_link;
    }
    else {
        $self->process_initial;
    }

    $t->{t}{plug_forgot_password} = $self->{OUTPUT};
}

sub process_q_code {
    my $self = shift;
    my $q    = $self->{Q};
    my $conf = $self->{CONF};

    my $code = $q->{ $conf->{q_code} };
    my $dbh  = $self->dbh;

    my $entry = ($dbh->selectall_arrayref(
        'SELECT * FROM `' . $conf->{code_table}
            . '` WHERE `code` = ?',
        { Slice => {} },
        $code,
    ) || [])->[0];

    unless ( $entry ) {
        $self->set_stage('code_invalid');
        $self->{OUTPUT} = '<p class="reset_code_expired">Your reset'
         . ' code has expired. Please try'
            . ' resetting your password again.</p>';
        return;
    }

    if ( has_value( $q->{pulfp_has_change_pass} ) ) {
        $self->check_change_pass
            or return;

        $self->set_new_pass( $entry );
        $self->set_stage('change_pass_done');
        $self->{OUTPUT} = '<p class="reset_pass_success">Your password'
            . ' has been successfully'
            . ' changed. You can now use it to '
            . (
                has_value( $conf->{login_page} )
                ? qq| <a href="$conf->{login_page}">log in</a>|
                : ' log in'
            )
            .'.</p>';
        return;
    }
    else {
        $self->set_stage('change_pass_ask');
        $self->{OUTPUT} = $self->make_change_pass_form;
    }
}

sub set_new_pass {
    my $self  = shift;
    my $entry = shift;
    my $q     = $self->{Q};
    my $conf  = $self->{CONF};
    my $dbh   = $self->dbh;

lib/App/ZofCMS/Plugin/UserLogin/ForgotPassword.pm  view on Meta::CPAN

}

sub check_change_pass {
    my $self = shift;
    my $q    = $self->{Q};
    my $conf = $self->{CONF};

    my ( $pass, $repass ) = @$q{ qw/pulfp_pass   pulfp_repass/ };
    unless ( has_value( $pass ) and length $pass >= $conf->{min_pass} ) {
        $self->set_stage('code_bad_pass_length');
        $self->{OUTPUT} = $self->make_change_pass_form(
            'Your new password must be at least '
            . $conf->{min_pass} . ' characters long.'
        );
        return;
    }

    unless ( has_value( $repass ) and $pass eq $repass ) {
        $self->set_stage('code_bad_pass_copy');
        $self->{OUTPUT} = $self->make_change_pass_form(
            'You did not retype your password correctly.'
        );
        return;
    }

    return 1;
}

sub make_change_pass_form {
    my ( $self, $error ) = @_;

lib/App/ZofCMS/Plugin/UserLogin/ForgotPassword.pm  view on Meta::CPAN

        \ask_login_form_template(),
        die_on_bad_params => 0,
    );

    $template->param(
        submit_button => $self->{CONF}{button_send_link},
        page => $self->{Q}{page},
        $show_form_error ? ( error => $show_form_error ) : (),
    );

    $self->{OUTPUT} = $template->output;
    $self->set_stage('initial');
}

sub process_ask_link {
    my $self = shift;

    my $q = $self->{Q};

    unless ( has_value( $q->{pulfp_login} ) ) {
        $self->set_stage('ask_error_login');

lib/App/ZofCMS/Plugin/UserLogin/ForgotPassword.pm  view on Meta::CPAN

            'Sorry, but due to abuse we have to limit the amount of'
            . ' requests. Please wait a short while and try again.'
        );
        return;
    }

    my $code = $self->create_access_code( $user );
    $self->email_code( $user, $code );

    $self->set_stage('emailed');
    $self->{OUTPUT} = '<p class="reset_link_send_success">Please check'
        . ' your email for further'
        . ' instructions on how to reset your password.</p>';
}

sub email_code {
    my $self = shift;
    my $user = shift;
    my $code = shift;
    my $conf = $self->{CONF};

lib/App/ZofCMS/Plugin/UserLogin/ForgotPassword.pm  view on Meta::CPAN

        email_template => \'templates/file.tmpl', # read template from file
    ...

    plug_user_login_forgot_password => {
        email_template => '<p>Blah blah blah...', # use this string as template
    ...

B<Optional>. Takes a scalar, a scalar ref, or C<undef> as a value.
Specifies L<HTML::Template> template to use when generating the email
with the reset link. When set to C<undef>, plugin will use its default
template (see OUTPUT section below). If you're using your own template,
the C<link> template variable will contain the link the user needs to follow
(i.e., use C<< <tmpl_var escape='html' name='link'> >>).
B<Defaults to:> C<undef> (plugin's default, see OUTPUT section below)

=head3 C<login_page>

    plug_user_login_forgot_password => {
        login_page => '/',
    ...

    plug_user_login_forgot_password => {
        login_page => '/my-login-page',
    ...

lib/App/ZofCMS/Plugin/UserLogin/ForgotPassword.pm  view on Meta::CPAN

=head3 C<use_stage_indicators>

    plug_user_login_forgot_password => {
        use_stage_indicators => 1,
    ...

B<Optional>. Takes either true or false values as a value. When set
to a true value, plugin will set "stage indicators" (see namesake section
below for details); otherwise, it won't set anything. B<Defaults to:> C<1>

=head1 STAGE INDICATORS & PLUGIN'S OUTPUT VARIABLE

All of plugin's output is spit out into a single variable in your
L<HTML::Template> template:

    <tmpl_var name='plug_forgot_password'>

This raises the question of controlling the bells and whistles on your
page with regard to what stage the plugin is undergoing
(i.e. is it displaying that form that asks for a login or the one that
is asking the user for a new password?). This is where I<stage indicators>

lib/App/ZofCMS/Plugin/UserLogin/ForgotPassword.pm  view on Meta::CPAN

=head2 C<plug_forgot_password_stage_change_pass_done>

    <tmpl_if name='plug_forgot_password_stage_change_pass_done'>
        Well, looks like you're all done with reseting your pass and what not.
    </tmpl_if>

This indicator shows that the final stage of plugin's run has been reached;
i.e. the user has successfully reset the password and can go on with
their other business.

=head1 OUTPUT

The plugin generates a whole bunch of various output; what's below should
cover all the bases:

=head2 Default Email Template

    <h2>Password Reset</h2>

    <p>Hello. Someone (possibly you) requested a password reset. If that
    was you, please follow this link to complete the action:



( run in 0.494 second using v1.01-cache-2.11-cpan-64827b87656 )