package Cpanel::Easy::Apache::UI::HTML::Help;

# cpanel - Cpanel/Easy/Apache/UI/HTML/Help.pm     Copyright(c) 2012 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use strict;
use warnings;

sub do_help_and_exit {
    my ($easy) = @_;
    ##
    #
    # DETOUR: The below if condition branches out to use new
    # template system to render the pages.
    #
    # Note: Old code is still kept (the code that follows the if condition) for
    # backward compatibility with 11.32.
    #
    ##
    require Cpanel::Easy::Apache::UI::HTML;

    # Check if requested web page is rendered through template
    if ( !Cpanel::Easy::Apache::UI::HTML->pre_1134_version() ) {

        # Call the corresponding method's '_tmpl' functions.
        show_help_tmpl($easy);
    }

    $easy->_header();
    print qq{<div style="margin-left: 20px;"><hr /><h3 style="font-size:24px;font-weight: bold;">Easy::Apache Help</h3>\n};
    print qq{<div style="margin-left: 20px;">\n};

    print <<"END_WHM_HELP";
    <div class="info_box">Below are some additional tools and options you might find useful. <br />Detailed EasyApache documentation can be found <a target="_blank" href="http://go.cpanel.net/ea">here</a>.</div><br />
    <form action="easyapache.pl" method="post">
       <input type="hidden" name="skip-cpanelsync" value="1" />
[<a href="javascript:display_quickpopupbox('--version','<iframe height=90% width=100% src=easyapache.pl?skip-cpanelsync=1&version=1 />')">Report version info of ea3, cpanel, and apache</a>]<br />
[<a href="javascript:display_quickpopupbox('--latest-versions','<iframe height=90% width=100% src=easyapache.pl?skip-cpanelsync=1&latest-versions=1 />')">List latest version of Apache, PHP, etc that this installs</a>]<br />
[<a href="javascript:display_quickpopupbox('--show-apache-defaults','<iframe height=90% width=100% src=easyapache.pl?skip-cpanelsync=1&show-apache-defaults=1 />')">Show default apache module information</a>]<br />
[<a href="easyapache.pl?skip-cpanelsync=1&perldoc=1" target="_blank">Cpanel::Easy Framework POD</a>]<br />
[<a href="easyapache.pl?skip-cpanelsync=1&only-tarballs-and-pkgs=1" target="_blank">Run only the tarball and system package check with verbose information</a>]<br />

<!-- TODO hook-info link -->

<input type="checkbox" value="1" name="skip-cpanel-version-check" /> Do not check to see that the server's cPanel is the latest available<br />
<!--<p>[ development and testing ]</p>-->
<input type="checkbox" value="1" name="debug" /> Include detailed debug data in output<br />
<input type="checkbox" value="1" name="debug-profile-revision" /> Output debug information about calculating the profile _meta->revision key<br />
<input type="checkbox" value="1" name="skip-rawopts" /> Do not use raw opts support<br />
<input type="checkbox" value="1" name="skip-rawenv" /> Do not use raw env support<br />
<input type="checkbox" value="1" name="skip-hooks" /> Do not execute any hook scripts<br />
<input type="checkbox" value="1" name="skip-custom-optmods" /> Do not build any opt mods that are not included in ea3 core (Note: these will still show in the UI for convienience)<br />
<input type="checkbox" value="1" name="output-syspkg-details" /> Output details about Cpanel::SysPkgs calls<br />
<input type="checkbox" value="1" name="stack" /> Turn on stack trace in cplog messages<br />
<input type="checkbox" value="1" name="perl-devel-profiler" /> Include process profile data in output<br />
<input type="submit" class="btn-primary primary default input-button" value="Submit" />
</form>
END_WHM_HELP

    print qq{<p align="center">[<a href="easyapache.pl?action=_pre_cpanel_sync_screen">Back</a>]</p>\n};
    print qq{</div>\n</div>\n};    # end indent
    $easy->_footer();
    exit;
}

##
# This method opens help page from List profiles page.
##
sub show_help_tmpl {
    my ($easy) = @_;

    my $tmpl_args = {
        'template_file' => 'ea_help.tmpl',
        'data'          => { 'header' => $easy->{'powered_by_line'} }
    };

    print "Content-type: text/html\n\n";

    Cpanel::Template::process_template(
        'whostmgr',
        $tmpl_args,
        { 'include_path' => "/var/cpanel/perl/easy/Cpanel/Easy/easy_apache_ui" }
    );
    exit;
}

1;
