$versions{'perl_module_checker-ext_lib.pl'} = '06.6.00.0000';

# Contains all sub routines (functions) for the main and core settings
# that the storefront (customer facing) functions use.

#######################################################################
#
# AgoraCart and all associated files, except where noted, are
# Copyright 2001 to Present jointly by K-Factor Technologies, Inc.
# and by C E Mayo (aka Mister Ed) at AgoraCart.com & K-Factor.net
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This copyright notice may not be removed or altered in any way.
#######################################################################

# Begin - loaded when lib read into manager.cgi. Sets up menu options.
{
    local ($modname) = 'perl_module_checker';
    register_extension( $modname, 'Perl Module Checker', $versions{$modname} );
    add_settings_choice(
        'Check Module Checker',
        ' Check Perl Modules ',
        'perl_module_checker_screen'
    );
    register_menu( 'perl_module_checker_screen', 'display_perlmodcheck_screen', $modname,
        'Display Perl Module Checker Output / Manager' );
}

#######################################################################

sub display_perlmodcheck_screen {

    local ( $test_perl_module, $test_perl_version ) = q{};
    my ( $core_modules, $my_modules, $optional_modules, $module_notes ) = q{};

    print &$manager_page_header( 'Password Editor', '', '', '', '' );

    $test_perl_version = sprintf( "%vd", $^V );
    print <<ENDOFTEXT;
    <h3 class="shadow rounded text-center" style="color: white; background-color: #4D6D84;">Perl Information</h3>
    <p class="text-center"><br>
    <b>Perl version:</b><span style="padding-left: 15px;"></span>$test_perl_version</p>
    <br><br>
ENDOFTEXT

    # core modules, should be okay
    foreach $x( qw( Archive::Extract
        Archive::Tar
        Encode
        File::Copy
        File::Copy::Recursive
        File::Find
        File::Path
        Locale::Country
        MIME::QuotedPrint) ) {
        eval "use $x";

        $test_perl_module =  "$@" ? 'unknown '."<!--\n$@\n-->" : $x->VERSION;

        $core_modules .= qq|<b>$x</b>: <span style="padding-left: 9px;"></span>( version: $test_perl_module ) <span style="padding-left: 18px;"></span>|;
        $core_modules .=  "$@" ? '<i class="fa fa-thumbs-down text-danger"></i>'."<!--\n$@\n-->" : '<i class="fa fa-thumbs-up text-success"></i>';
        $core_modules .= "<br>\n";
        $module_notes = q{};
    }

    print qq|<h3 class="shadow rounded text-center" style="color: white; background-color: #4D6D84;">Perl Modules - Core</h3>\n<p style="padding-left: 3em;"><br>|;
    print $core_modules;
    print "</p><br><br>";

    print qq|<h3 class="shadow rounded text-center" style="color: white; background-color: #4D6D84;">Perl Modules - Required</h3>\n<p style="padding-left: 3em;"><br>|;


    # required modules. Some we install local to script
    foreach $x(qw(
        CGI::Simple::Standard
        HTTP::BrowserDetect
        HTTP::Request
        LWP::UserAgent
        LWP::Simple
        XML::Simple
      )) {
      eval "use $x";

      $test_perl_module =  "$@" ? 'n/a '."<!--\n$@\n-->" : $x->VERSION;

      if ( $x eq 'CGI::Simple::Standard' ) {
          $module_notes = q{ - Faster version of CGI, Installed with AgoraCart };
      }
      elsif ( $x eq 'HTTP::BrowserDetect' ){
          $module_notes = q{ - Installed with AgoraCart };
      }

      $my_modules .= qq|<b>$x</b>: <span style="padding-left: 9px;"></span>( version: $test_perl_module $module_notes ) <span style="padding-left: 18px;"></span>|;
      if ( $x eq "CGI::Simple::Standard" || $x eq "HTTP::BrowserDetect" || $x eq "XML::Simple" ) {
          $my_modules .=  "$@" ? '<i class="fa fa-thumbs-down text-danger"></i><span class="text-success" style="padding-left: 18px;"> But we will install a copy</span>'."<!--\n$@\n-->" : '<i class="fa fa-thumbs-up text-success"></i>';
      }
      elsif ($x eq "GD") {
          $my_modules .=  "$@" ? '<i class="fa fa-thumbs-down text-danger"></i><span class="text-success" style="padding-left: 18px;">-- <b>Store & Manager areas will work ok</b> --</span><span class="text-danger"> but you cannot use automatic image resizing for product images on product add & edit screens</span>'."<!--\n$@\n-->" : '<i class="fa fa-thumbs-up text-success"></i>';
      }
      else {
          $my_modules .=  "$@" ? '<i class="fa fa-thumbs-down text-danger"></i>'."<!--\n$@\n-->" : '<i class="fa fa-thumbs-up text-success"></i>';
      }
      $my_modules .= "<br>\n";
      $module_notes = q{};
    }
    print $my_modules;
    print "</p><br><br><br>";

    print qq|<h3 class="shadow rounded text-center" style="color: white; background-color: #4D6D84;">Perl Modules - Cart Manager Specific</h3>\n<p style="padding-left: 3em;"><br>|;

    # required modules. Some we install local to script
    #Authen::SASL
    foreach $x(qw(
        GD
        IO::Socket::SSL
        MIME::Lite
        Net::SMTP
        Net::SMTPS
      )) {
      eval "use $x";

      $test_perl_module =  "$@" ? 'n/a '."<!--\n$@\n-->" : $x->VERSION;

      if ( $x eq 'GD' ){
          $module_notes = q{ - Optional: for image resizing in product add/edit otherwise skipped };
      }
      elsif ( $x eq 'IO::Socket::SSL' ){
          $module_notes = q{ - Optional, but required for encrypted messaging in Net::SMTP };
      }
      elsif ( $x eq 'Net::SMTP' ){
          $module_notes = q{ - Optional, but required For SMTP Email };
      }
      $optional_modules .= qq|<b>$x</b>: <span style="padding-left: 9px;"></span>( version: $test_perl_module $module_notes ) <span style="padding-left: 18px;"></span>|;
      $optional_modules  .=  "$@" ? '<i class="fa fa-thumbs-down text-danger"></i>'."<!--\n$@\n-->" : '<i class="fa fa-thumbs-up text-success"></i>';
      $optional_modules  .= "<br>\n";
      $module_notes = q{};
    }
    print $optional_modules;

    print q|</p><div class="row"><div class="col-xs-12 col-sm-12"><p><br><br><br></p></div></div>|;
    print &$manager_page_footer;

}

#######################################################################

1;
