$versions{'product_misc-ext_lib.pl'} = '06.6.00.0001';

# Contains misc sub routines (functions) to handle category metatags,
# userfield renaming for product DB displays, etc.
#
# Does not need to be 5, 10 or 20 user specific like other 2 product files.

#######################################################################
#
# 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.
#
#######################################################################

require_supporting_libraries( __FILE__, __LINE__, "$sc_userfieldsfile" );

{
    local ($modname) = 'product_misc';
    register_extension( $modname, 'Product DB Misc', $versions{$modname} );
    register_menu( 'rename_userfields_screen', 'display_user_naming_screen',
        $modname, 'Rename DB UserFields' );
    register_menu(
        'SubmitEditUserfields', 'action_submit_edit_userfields',
        $modname,  'Write Edited UserField Names'
    );
    add_settings_choice(
        'UserFields - Rename for Manager Displays',
        'UserFields - Rename in Managers',
        'rename_userfields_screen'
    );
    register_menu(
        'edit_category_descriptions_screen', 'edit_category_descriptions_screen',
        $modname,  'Display Category Description MetaTag Screen'
    );
    register_menu(
        'edit_catdescription', 'edit_category_descriptions_screen',
        $modname,  'Edit Individual Category Description MetaTag Screen'
    );
    register_menu(
        'UpdateCategoryDescriptionTag', 'edit_category_descriptions_screen',
        $modname,  'Update/Save Individual Category Description MetaTag'
    );
    add_merchtools_settings_choice(
        'Category: productPage &amp; SEO MetaTags',
        'Category: productPage &amp; SEO MetaTags',
        'edit_category_descriptions_screen'
    );
}

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

sub action_submit_edit_userfields {
    local ($myset) = q{};

    my $tempthingy = 2;
    while ( $tempthingy <= $sc_userfields_available ) {
        my $tempthingy2 = 'user' . "$tempthingy";
        if ( $in{$tempthingy2} ) {
            $myset .= "\$$tempthingy2 = \"$in{$tempthingy2}\";\n";
            $$tempthingy2 = $in{$tempthingy2};
        }
        else {
            $myset .= "\$$tempthingy2 = \"User $tempthingy\";\n";
        }
        $tempthingy++;
    }

    update_userfield_names( '$sc_userfieldsfile', $myset );
    display_user_naming_screen();
}

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

sub update_userfield_names {
    my ( $item, $stuff ) = @_;
    $user_file_settings{$item} = $stuff;
    my ( $zitem );

    get_file_lock("$sc_userfieldsfile.lockfile");
    open( USERFILE, ">$sc_userfieldsfile" ) || my_die("Can't Open $sc_userfieldsfile");
    foreach $zitem ( sort( keys %user_file_settings ) ) {
        print( USERFILE $user_file_settings{$zitem} );
    }
    close(USERFILE);
    release_file_lock("$sc_userfieldsfile.lockfile");
    require_supporting_libraries( __FILE__, __LINE__, "$sc_userfieldsfile" );
}

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

sub display_user_naming_screen {

    local ($filename) = "$mgrdir/";
    print &$manager_page_header( 'User Field Name Editor', '', '', '', '' );

    print <<ENDOFTEXT;
<h1 class='mgr-page-title'><b>Database UserField Names Editor</b></h1>
<p><br></p>

<p class="well">This area allows you to change the names of the database userfields as they are displayed in the Add Product and Edit Product screens.  This only affects how they are displayed to you in the managers and does not change the names of the user fields anywhere else (i.e.: token names/values, code names, etc).</p>
<p><br></p>

ENDOFTEXT

    if ( $in{'system_edit_success'} ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-success">
        <h4 class="text-primary mgr-center">UserField names have been successfully updated.</h4>
    </div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
ENDOFTEXT
    }

    print qq~
<p><br></p>
<form action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<div class="col-xs-12 col-sm-12">

~;

    my $tempthingy = 2;
    while ( $tempthingy <= $sc_userfields_available ) {
        my $tempthingy2 = "user" . "$tempthingy";
        print qq~
<p><b>New Name for $tempthingy2 (30 characters max):</b><input
value='$$tempthingy2' name="$tempthingy2" class="form-control" maxlength="30"></p>
<p><hr></p>
~;
        $tempthingy++;
    }
    print qq~
</div>
<div class="col-xs-12 col-sm-12"><p><br></p></div>
<input type="hidden" name="system_edit_success" value="yes">
<input name="SubmitEditUserfields" value="Submit" type="hidden">
<button class="btn btn-primary btn-lg btn-block">Submit User Field Name Changes</button>
<p><br><br><br></p>
</form>
~;
    print &$manager_page_footer;
}

#######################################################################
#
# get a row from the product shipping dimensions database.
# added by Mister Ed May 17, 2007
#
#######################################################################

sub get_prod_shipping_dimensions_in_db_row_for_edit {
    my ($product_id) = @_;
    my ( $db_product_id, $save_the_line, $filename, $result );
    my ( $sku, $boxindicator, $length, $width, $height, $girth, $boxtype,
        $alt_origin_postalcode, $alt_origin_stateprov );
    $db_product_id = q{};

    open( DATAFILE, "$mc_shipfilename" )
      || file_open_error( "$mc_shipfilename", 'Read Dimensions Database', __FILE__, __LINE__ );

    while ( ( $line = <DATAFILE> ) && ( $product_id ne $db_product_id ) ) {
        chomp($line);
        (
            $sku, $boxindicator, $length, $width, $height, $girth, $boxtype,
            $alt_origin_postalcode, $alt_origin_stateprov
        ) = split( /\|/, $line );
        $save_the_line = $line;
        $db_product_id = $sku;
    }

    if ( $product_id eq $db_product_id ) {
        $result = "$save_the_line";
    }
    close(DATAFILE);

    return $result;

}

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

sub put_prod_dimensions_raw_line {
    my ( $product_id, $db_raw_line ) = @_;
    local ( $result, $db_product_id, $ProductEditSku ) = q{};
    my ( $junk, $line, @lines );

    #Note: could check to see if $product_id and $ProductEditSku match!
    ( $ProductEditSku, $junk ) = split( /\|/, $db_raw_line, 2 );

    get_file_lock("${mc_shipfilename}.lock");
    open( OLDFILE, "$mc_shipfilename" )  || my_die("Can't Open $mc_shipfilename");
    @lines = <OLDFILE>;

    #print @lines;
    close(OLDFILE);
    open( NEWFILE, ">$mc_shipfilename" ) || my_die("Can't Open $mc_shipfilename");

    foreach $line (@lines) {

        chomp $line;
        ( $ProductEditSku, $junk ) = split( /\|/, $line, 2 );

        if ( $ProductEditSku eq $product_id ) {
            print NEWFILE $db_raw_line . "\n";
            $result = 1;
        }
        else {
            print NEWFILE $line . "\n";
        }
    }

    if ( $result ne 1 ) {
        print NEWFILE $db_raw_line . "\n";
        $result = 1;
    }

    close(NEWFILE);
    release_file_lock("${mc_shipfilename}.lock");

    return $result;

}

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

sub edit_category_descriptions_screen {

    local ( $message, $pageTitle, @categories, $cat_str, $cat_str_del, $productPage_dir_files );
    local ( %db_ele, %category_list, %realMetaDBlist, @realMetaDBarray );
    my (@values, $robotlist_string, $robot_tag_string, @robotlist ) = q{};
    my ( $helper, $deleter_helper, $temp_meta_category, $temp_catpagebreak,$meta_description, $inx, $mc_meta_category_found, $newfile, $line, $cat_meta_error_message ) = q{};
    my ( $temp_noarchive_checked, $temp_noimageindex_checked, $temp_nofollow_checked, $temp_noindex_checked ) = q{};
    my $submit_button_text = 'Update Product Category Description / Meta Tag';
    my $robot_count = 0;
    if ( $in{'category'} ) {
        $in{'category'} =~ /([\w\s\-\_\>\/\&\.\,\+\:]+)/;  # untaint
        $in{'category'} = $1;
    }
    my $cat_holder = qq|$in{'category'} <input type="hidden" name="category" value="$in{'category'}">|;

    $in{'catproductdisplayname'} =~ /([\w\s\-\_\>\/\&\.\,\'\+\;\:]+)/;  # untaint
    $in{'catproductdisplayname'} = $1;


    print &$manager_page_header( 'Edit Product Category MetaTags', '', '', '', '' );

    require_supporting_libraries( __FILE__, __LINE__, "$sc_template_widgets_file" );

    if ( $sc_enable_category_metatag_db ne 'yes' ) {
        $cat_meta_error_message = "WARNING: The Custom Product Category MetaTag Database is NOT Enabled. Any tags edited/created will not be used by your store. Go to the 'Meta Tags' tab of the 'Main / Core Settings' manager to enable.<br><br>";
    }

    if ( ( $in{'UpdateCategoryDescriptionTag'} && $in{'category'} && $in{'catmetadescription'} )
            || ( $in{'category'} && $in{'deleteThisCategoryMetatagListing'} ) ) {
        $in{'catmetadescription'} =~ s/\"//g;
        $in{'catmetadescription'} =~ s/<//g;
        $in{'catmetadescription'} =~ s/\`//g;
        $in{'catmetadescription'} =~ s/\$//g;
        $in{'catmetadescription'} =~ s/\%//g;
        $in{'catmetadescription'} =~ s/\@//g;
        $in{'catmetadescription'} =~ s/\}//g;
        $in{'catmetadescription'} =~ s/\{//g;
        $in{'catmetadescription'} =~ s/\]//g;
        $in{'catmetadescription'} =~ s/\[//g;
        $in{'catmetadescription'} =~ s/\|//g;
        $in{'catmetadescription'} =~ s/\n//g;
        $in{'catmetadescription'} =~ s/\t//g;
        $in{'catmetadescription'} =~ s/\<//g;

        @values = param('metarobots');
        foreach $robot (@values) {
            if ( $robot_count == 0 && $robot ) {
                $robotlist_string = "$robot";
            }
            elsif ($robot_count > 0 && $robot ) {
                $robotlist_string .= ", $robot";
            }
            $robot_count++;
        }
        if ( $robotlist_string ) {
            $robot_tag_string = qq|<meta name="robots" content="$robotlist_string">|;
        }

        $mc_meta_category_found = 1;
         if ( -e "$sc_cat_desc_data_path" ) {
            open( CATDESCMETA, "$sc_cat_desc_data_path" );
            while ( $line = <CATDESCMETA>  ) {
                ($temp_meta_category, $category_display_name, $meta_lang, $meta_layout, $temp_catpagebreak, $meta_description, $temp_robotlist, $temp_robot_metatag, $catwhichpagetitle, $temp_cat_breadcrumb, $breadiscustomformat, $temp_google_cat_id) = split(/\|/,$line);
                if ( $temp_meta_category eq "$in{'category'}" ) {
                    if ( !( $in{'deleteThisCategoryMetatagListing'} ) ) {
                        $newfile .= "$temp_meta_category|$in{'catproductdisplayname'}|$meta_lang|$in{'catproductpagetemplate'}|$in{'catproductpagebreak'}|$in{'catmetadescription'}|$robotlist_string|$robot_tag_string|$in{'catwhichpagetitle'}|$in{'catproductbreadcrumbs'}|$in{'catbreadiscustomformat'}|$in{'catproductgoogleid'}\n";
                    }
                    $mc_meta_category_found = q{};
                }
                else {
                    $newfile .= "$line";
                }
            }
            close(CATDESCMETA);
        }
        if ( $mc_meta_category_found ) {
            $newfile .= "$in{'category'}|$in{'catproductdisplayname'}|$sc_lang_path|$in{'catproductpagetemplate'}|$in{'catproductpagebreak'}|$in{'catmetadescription'}|$robotlist_string|$robot_tag_string|$in{'catwhichpagetitle'}|$in{'catproductbreadcrumbs'}|$in{'catbreadiscustomformat'}|$in{'catproductgoogleid'}\n";
            $mc_meta_category_found = q{};
        }
        open( CAT3META, ">$sc_cat_desc_data_path" );
            print CAT3META $newfile;
        close(CAT3META);
    }

    if ( $in{'category'} && $in{'deleteThisCategoryMetatagListing'} eq '' ) {
        $pageTitle = "Product Category: Layout &amp; MetaTags";
        $message =
qq~Select the <b>productPage</b> layout for the <b>$in{'category'}</b> product category, but only if you need something different for the category than the default productPage.inc file used storewide. Leave blank (the default) if you do not wish to use a custom or other standard PPINC layout file for the category.
<br><br>Edit the product category description used in the HTML header meta tags for each category page displayed in your store front for the <b>$in{'category'}</b> product category. The HTML / SEO descriptions are used in the page description meta tag which are used by search engines to index your product category pages.
<br><br>To add main/top level categories that you wish to define separate layouts and metatag information for, use the "new entry" option when chosing a product category to edit in this on this screen.
<br><br>To add sub-categories that are under main/top level categories that are locked OR that you wish to define separate layouts and metatag information for, use the "new entry" option when chosing a product category to edit in this on this screen.
<br><br>Limit 155 characters, but shorter is better as some customization is added to make the page unique if your enter less than 100 characters for the meta tag description. If nothing exists currently, simply add the text you desire. If left blank, one is built using some keywords from the products displayed on that particular page.
<br><br>Do not enter single or double quotes, nor any other meta-characters ( <i>non-alphanumeric characters and those that you would use the "shift key" plus a key to type</i> such as \$,\#,\%,&amp;,\@,*,',",-,<,>,?,/, etc )
<br><br>The Description and the Display Name for the product category allows these 11 meta-characters: . , ; : &amp; _ - / ' + >
<br><br>Breadcrumbs for the product category allows these 3 meta-characters: ; &amp; >
~;
    }
    else {
        $pageTitle = "Select a Product Category to Manage";
        $message = q|Select the (or add a "new entry") Product Category to select the productPage template/layout (aka PPINC) and also edit the HTML / SEO metatag description for the category. The productPage.inc choice determines the product page listings layout for the product category. The HTML / SEO descriptions are used in the page description meta tag used by search engines to index your product category pages.|;
    }

###########
    $sc_categorylist_only = '1';
    get_prod_db_element( $db{"product"}, *db_ele );
    foreach $sku ( keys %db_ele ) {
        $category = $db_ele{$sku};
        $category_list{$category} = 1;
    }
    $sc_categorylist_only = q{};


    if ( -e "$sc_cat_desc_data_path" ) {
        open( CAT2META, "$sc_cat_desc_data_path" );
        while ( $line = <CAT2META> )  {
            ($temp_meta_category, $metadisplayname, $meta_lang, $meta_layout, $meta_description, $temp_robotlist, $temp_robot_metatag, $catwhichpagetitle, $temp_cat_breadcrumb, $breadiscustomformat, $temp_google_cat_id) = split(/\|/,$line);
            $category_list{$temp_meta_category} = 1;
            $realMetaDBlist{$temp_meta_category} = 1;
        }
        close(CAT2META);
    }
###########
    @categories = sort( keys %category_list );
    @realMetaDBarray = sort( keys %realMetaDBlist );
    $cat_str = "<option>New Entry</option>\n";
    foreach $inx (@categories) {
        $cat_str .= "<option>$inx</option>\n";
    }
    $cat_str_del = q{};
    foreach $inx (@realMetaDBarray) {
        $cat_str_del .= "<option>$inx</option>\n";
    }

    if ( $in{'category'} ) {
        opendir( DIRTOREAD, "$sc_product_layouts_dir" );
        @myfiles = readdir(DIRTOREAD);
        closedir(DIRTOREAD);
        foreach $zfile (@myfiles) {
            if ( ( $zfile =~ /\.inc$/ )
            && ( $zfile !~ /Master\.inc$/i )
            && ( $zfile !~ /$sc_lang_path\.inc$/i )
            && ( $zfile !~ /mgr_lang\.inc$/i )
            && ( $zfile !~ /template_homezone/i )
            && ( $zfile !~ /template_manifest/i )
            && ( $zfile !~ /template_widgets/i )
             ) {
                $productPage_dir_files .=  qq~<option value="$zfile">$zfile</option>\n~;
            }
        }
    }

    $helper = qq~
<div class="row col-xs-12 col-sm-12" style="border-width:0px; border-style:hidden;">
    <form class="pull-right" action="manager.cgi" method="post">
    <input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
    <button class="btn btn-sm btn-success" name="edit_catdescription" value="Edit Category Description MetaTag -->">Edit Product Category PPINC Layout &amp; MetaTag --></button> &nbsp;&nbsp;
    <select name="category">$cat_str</select>
    </form>
</div>
~;
    if ( $username !~ /test|username/i ) {
        $deleter_helper = qq~
<div class="row col-xs-12 col-sm-12" style="border-width:0px; border-style:hidden;">
    <p><br><br></p>
    <form class="pull-right" action="manager.cgi" method="post">
    <input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
    <input type="hidden" name="edit_catdescription" value="sortof">
    <button class="btn btn-sm btn-warning" name="deleteThisCategoryMetatagListing" value="yes">Delete This Product Category PPINC Layout &amp; MetaTag Listing --></button> &nbsp;&nbsp;
    <select name="category">$cat_str_del</select>
    </form>
    <p><br><br><br><br></p>
</div>
~;
    }
    else {
        $deleter_helper = q{};
    }

    print <<ENDOFTEXT;
<h1 class='mgr-page-title'><b>$pageTitle</b></h1>
<p><br></p>

<p class="well">$message</p>
<p><br></p>
ENDOFTEXT

    if ( ( $in{'UpdateCategoryDescriptionTag'} ) && ( $in{'category'} ) && ( $in{'catmetadescription'} ) ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-success">
        <h4 class="text-primary mgr-center">Product Category Description MetaTag for $in{'category'} successfully edited!</h4>
    </div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
ENDOFTEXT
    }
    elsif ( ( $in{'deleteThisCategoryMetatagListing'} ) && ( $in{'category'} ) ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-warning">
        <h4 class="text-primary mgr-center">Product Category Description MetaTag for $in{'category'} successfully deleted!</h4>
    </div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
ENDOFTEXT
    }

    if ( $cat_meta_error_message ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-danger">
        <h4 class="text-primary mgr-center">$cat_meta_error_message</h4>
    </div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
ENDOFTEXT
    }

    if ( $conv_result ) {
        print <<ENDOFTEXT;
<div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 hidden-xs">
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 bg-warning">
        <h4 class="text-primary mgr-center">$conv_result</h4>
    </div>
</div>
<div class="row col-xs-12 col-sm-12"><p><br></p></div>
ENDOFTEXT
    }

    print $helper;

    if ( ( ( !( $in{'category'} ) ) || $in{'deleteThisCategoryMetatagListing'} )
        || ( ( $in{'UpdateCategoryDescriptionTag'} ) && ( $in{'category'} ) && ( $in{'catmetadescription'} ) ) ){
        print $deleter_helper;
    }

    if ( ( $in{'category'} ) && ( $in{'edit_catdescription'} ) && ( $in{'deleteThisCategoryMetatagListing'} eq '' ) ) {
        $mc_meta_category_found = q{};
         if (-e "$sc_cat_desc_data_path") {
            open( CATDESCREAD, "$sc_cat_desc_data_path" );
            while ( ($line = <CATDESCREAD>) && ( $mc_meta_category_found eq '' ) ) {
                ($temp_meta_category,$metadisplayname,$meta_lang,$meta_layout,$breaklock,$meta_description,$temp_robotlist,$temp_robot_metatag, $catwhichpagetitle, $temp_cat_breadcrumb, $breadiscustomformat, $temp_google_cat_id) = split(/\|/,$line);
                if ( $temp_meta_category eq $in{'category'} ) {
                    $mc_meta_category_found = 1;
                    chomp($meta_description);
                }
            }
            close(CATDESCREAD);
        }
        if ( $mc_meta_category_found eq '' ) {
            ( $meta_layout, $meta_description, $temp_robotlist, $catwhichpagetitle, $temp_cat_breadcrumb, $breadiscustomformat, $temp_google_cat_id ) = q{};
            $metadisplayname = $in{'category'};
        }
        if ($breaklock eq '' ) {
          $breaklock = 'no';
        }
        if ( $in{'category'} eq 'New Entry' ) {
            $cat_holder = q|<input name="category" type="text" class="form-control" maxlength="80">|;
            $submit_button_text = 'Submit New Product Category Description / Meta Tag';
        }

        if ($temp_robotlist) {
            @robotlist = split(/,/,$temp_robotlist);
            foreach $item (@robotlist) {
                $item =~ s/\s//g;
                if ( $item  eq 'noarchive' ) {
                    $temp_noarchive_checked = 'checked';
                }
                elsif ( $item  eq 'noimageindex' ) {
                    $temp_noimageindex_checked = 'checked';
                }
                elsif ( $item  eq 'nofollow' ) {
                    $temp_nofollow_checked = 'checked';
                }
                elsif ( $item  eq 'noindex' ) {
                    $temp_noindex_checked = 'checked';
                }
            }
        }


        print <<ENDOFTEXT;
<form action="manager.cgi" method="post">
<input type="hidden" name="mgr_seshun" value="$in{'mgr_seshun'}">
<p><hr></p>

<p><b>Product Category:</b><span style="padding-left: 25px;"></span>
<span style="font-size: 18px;"><b>$cat_holder</b></span></p>
<p><hr></p>


<p><b>Name to Display for this Product Category: &nbsp; <a data-toggle="collapse" href="#categoryDisplayName" aria-expanded="false" aria-controls="categoryDisplayName"><i class="fa fa-info-circle"></i></a></b><input name="catproductdisplayname" type="text" class="form-control" value="$metadisplayname" required></p>
<div class="collapse" id="categoryDisplayName">
     <div class="well">
         <p>Default: blank</p>
         <p>Use thise field to change the name used for the title of the product category on product category page layouts/pages.</p>
         <p>You can use this to change product category names in your product database that might be too generic or too short.</p>
     </div>
 </div>
 <p><hr></p>

<p><b>Use Which Page Title:&nbsp; <a data-toggle="collapse" href="#catPageTitle" aria-expanded="false" aria-controls="catPageTitle"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span>
<select name="catwhichpagetitle">
<option value="$catwhichpagetitle">$catwhichpagetitle</option>
<option value="display name">Display Name</option>
<option value="breadcrumbs">Breadcrumbs</option>
</select></p>
<div class="collapse" id="catPageTitle">
    <div class="well">
        <p>Default: DISPLAY NAME.</p>
        <p>Select BREADCRUMBS if you wish to use the breadcrumb text entered below.</p>
    </div>
</div>
<p><hr></p>

<p><b>Breadcrumb String for this Product Category: &nbsp; <a data-toggle="collapse" href="#categoryBreadCrumbs" aria-expanded="false" aria-controls="categoryBreadCrumbs"><i class="fa fa-info-circle"></i></a></b><br>(example: Media &gt; DVDs &amp; Videos &gt; Film &amp; Television Digital Downloads)<input name="catproductbreadcrumbs" type="text" class="form-control" value="$temp_cat_breadcrumb"></p>
<div class="collapse" id="categoryBreadCrumbs">
    <div class="well">
        <p>Default: blank. Supports Google Merchant category breadcrumb</p>
        <p>Use for categories you wish to show a breadcrumb format to describe the product category.</p>
        <p>Can be used for Google Merchant export feeds (separate add-on) as the category data field.</p>
        <p>This field used first if entered, otherwise the "Name to Display" for this category will be used.</p>
        <p>Gold Version licenses/members can use a handy category lookup tool at: <a href="https://members.agoracart.com/google-product-id-tool.php" target="_blank">https://members.agoracart.com/google-product-id-tool.php</a></p>
        <p>To get the category list files (.txt or .xls) or for more information, see <a href="https://support.google.com/merchants/answer/6324436" target="_blank">https://support.google.com/merchants/answer/6324436</a></p>
    </div>
</div>
<p><hr></p>

<p><b>Is Breadcrumb String a Custom Format:&nbsp; <a data-toggle="collapse" href="#breadcrumbCustFormat" aria-expanded="false" aria-controls="breadcrumbCustFormat"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span>
<select name="catbreadiscustomformat">
<option value="$breadiscustomformat">$breadiscustomformat</option>
<option value="no Google Format">no, Official Google Format</option>
<option value="no Other Format">no, Other Format</option>
<option value="yes">yes</option>
</select></p>
<div class="collapse" id="breadcrumbCustFormat">
    <div class="well">
        <p>Default: NO.</p>
        <p>Select YES if Google or other service does not have a breadcrumb that fits your product category. Setting to YES affects Google Merchant data feed exports if add-on is installed.</p>
    </div>
</div>
<p><hr></p>

<p><b>Google Merchant Product Category ID#: &nbsp; <a data-toggle="collapse" href="#categoryGoogleID" aria-expanded="false" aria-controls="categoryGoogleID"><i class="fa fa-info-circle"></i></a></b><input name="catproductgoogleid" type="number" class="form-control" value="$temp_google_cat_id"></p>
<div class="collapse" id="categoryGoogleID">
    <div class="well">
        <p>Default: blank. Supports Google Merchant category ID numbers</p>
        <p>Use for data exports for Google product feeds, more efficient and creates a smaller file.</p>
        <p>Can be used for Google Merchant export feeds (separate add-on) as the category data field.</p>
        <p>This field used first by the Google Merchant data feed exporter if entered, otherwise the breadcrumbs above will be used (or the default if no breadcrumbs entered) for this category.</p>
        <p>Gold Version licenses/members can use a handy category lookup tool at: <a href="https://members.agoracart.com/google-product-id-tool.php" target="_blank">https://members.agoracart.com/google-product-id-tool.php</a></p>
        <p>To get the category list files (.txt or .xls) or for more information, see <a href="https://support.google.com/merchants/answer/6324436" target="_blank">https://support.google.com/merchants/answer/6324436</a></p>
    </div>
</div>
<p><hr></p>

<p><b>Lock productPage Template (ppinc):&nbsp; <a data-toggle="collapse" href="#ppincFileLock" aria-expanded="false" aria-controls="ppincFileLock"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span>
<select name="catproductpagebreak">
<option value="$breaklock">$breaklock</option>
<option value="yes">yes</option>
<option value="no">no</option>
</select></p>
<div class="collapse" id="ppincFileLock">
    <div class="well">
        <p>Default: NO.</p>
        <p>Only applies main or top level categories that have a PPINC template (productPage .inc file) selected below on this screen.</p>
        <p>Select YES to allow level 2 and level 3 sub-categories under this product category to use <b>&ppinc=file-name-extension-here</b> header overrides in the URL. Only applies if <b>$cat_holder</b> is a top/main level product category.</p>
        <p>Select NO to lock in selected PPINC (productPage .inc file) selected below on this screen. This will lock the layout for this category or sub-category. It will also lock the layout for all sub-categories entered under it, but only if <b>$cat_holder</b> is a main/top level category.</p>
        <p>Sub-Categories can override main/top level PPINC locks if an metatag entry and layout is selected for the sub-category.</p>
    </div>
</div>
<p><hr></p>

<p><b>Select productPage Template (ppinc):&nbsp; <a data-toggle="collapse" href="#ppincFile" aria-expanded="false" aria-controls="ppincFile"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span>
<select name="catproductpagetemplate">
<option value="$meta_layout">$meta_layout</option>
<option value=""></option>
$productPage_dir_files
</select></p>
<div class="collapse" id="ppincFile">
    <div class="well">
        <p>Storewide Default: productPage.inc  (the default product category productPage layout/template (PPINC), unless a layout is specifially chosen for this category).</p>
        <p>Select the productPage template/layout (aka ppinc - productPage include) that you wish to use for this category and sub-categories.</p>
        <p>Unless the lock is broken (set to YES above) or additional enteries are made for desired sub-categories individually, the selected template/layout will affect for all pages displaying products within the specific product category and ALL sub-categories added under it, if a main/top level category.</p>
        <p>You may create more productPage templates and place them in <b>$sc_product_layouts_dir</b> of your store directory tree.</p>
    </div>
</div>
<p><hr></p>


<p><b>Product Category Description MetaTag:</b><span style="padding-left: 25px;"></span>
<textarea name="catmetadescription" rows="6" maxlength="155" class="form-control" wrap="soft">$meta_description</textarea></p>
<p><hr></p>

<p><b>Robot Metatags - For only this Category &nbsp; <a data-toggle="collapse" href="#robotMetaTags" aria-expanded="false" aria-controls="robotMetaTags"><i class="fa fa-info-circle"></i></a></b><span style="padding-left: 25px;"></span>
<div class="checkbox">
    <label>
        <input type="checkbox" name="metarobots" value="noarchive" aria-label="noarchive" $temp_noarchive_checked> noarchive <i>(recommended)</i>
    </label>
</div>
<div class="checkbox">
    <label>
        <input type="checkbox" name="metarobots" value="noimageindex" aria-label="noimageindex" $temp_noimageindex_checked> noimageindex <i>(recommended)</i>
    </label>
</div>
<div class="checkbox">
    <label>
        <input type="checkbox" name="metarobots" value="nofollow" aria-label="nofollow" $temp_nofollow_checked> nofollow
    </label>
</div>
<div class="checkbox">
    <label>
        <input type="checkbox" name="metarobots" value="noindex" aria-label="noindex" $temp_noindex_checked> noindex
    </label>
</div>
</p>
<div class="collapse" id="robotMetaTags">
     <div class="well">
         <p>Default: The robot meta tags set in the <a href=manager.cgi?mgr_seshun=$in{'mgr_seshun'}&main_settings_screen=yes>main/core settings manager under the metatags tab</a>
         <p>Leave blank to use sitewide defaults.</p>
         <p>Select the robot tags you need for this product category or sub-category. Will override sitewide defaults, so select all those you need for this category.
         <p><b>Note:</b> Robot tag attributes selected will apply to all sub-categories under a main category selected, however you can override main category settings by adding (select New Entry) or editing sub-category entries in the meta tag database.
         <p><b>noarchive:</b> Do not show a "Cached" link in search results. Recommended for most sites.</p>
         <p><b>noimageindex:</b> Do not index images on this page. Recommended for most sites.</p>
         <p><b>nofollow:</b> Do not follow the links on this page.</p>
         <p><b>noindex:</b> Do not show this page in search results and do not show a "Cached" link in search results. For sites or pages you do not need shown complete details in search results, such as a privacy page, legal details, personal pages, etc.<br>
         Note: <i>we have observed google results showing results for the site but no site information/details when this is used sitewide.</i></p>
     </div>
 </div>
 <p><hr></p>

<input name="UpdateCategoryDescriptionTag" value="Submit" type="hidden">
<button class="btn btn-primary btn-lg btn-block">$submit_button_text</button>
</form>

ENDOFTEXT
    }

    print <<ENDOFTEXT;
<p><br><br><br></p>
ENDOFTEXT
    print &$manager_page_footer;
}

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

1;
