<?php
require_once DIR_CORE.'files-'.DB_TYPE.'.php';
require_once DIR_CORE.'files.php';

require_once DIR_CORE.'products-'.DB_TYPE.'.php';
require_once DIR_CORE.'products.php';

if( $a == 'List' ){
  $sProductsList = listProducts( 'products_list.tpl' );
  $content .= !empty( $sProductsList ) ? $sProductsList : $tpl->tbHtml( 'products_list.tpl', 'NOT_FOUND' );
}
elseif( $a == 'More' && isset( $iProduct ) && is_numeric( $iProduct ) ){
  $aData = throwProduct( $iProduct );
  if( isset( $aData ) ){
    $aFiles =  listFiles( $iProduct, 'products_details.tpl', 1 );

    if( empty( $aData['sDescriptionFull'] ) ){
      $aData['sDescriptionFull'] = $aData['sDescriptionShort'];
    }

    $aData['sDescriptionFull']  = changeTxt( $aData['sDescriptionFull'], 'nlNds' );
    $aData['sCategories']       = throwTreeForProduct( $aData['aCategories'], 'products_details.tpl' );

    $sTitleBefore = $aData['sName'].' - ';

    if( isset( $aFiles['sPhotos'] ) || isset( $aFiles['sFiles'] ) ){
      $sMorePhotosLink =  $tpl->tbHtml( 'products_details.tpl', 'MORE_PHOTOS_LINK' );
      $sMorePhotosTxt =   $tpl->tbHtml( 'products_details.tpl', 'MORE_PHOTOS_TXT' );
    }

    $content .= $tpl->tbHtml( 'products_details.tpl', 'SHOW' );
  }
  else
    $content .= $tpl->tbHtml( 'messages.tpl', 'NOT_EXISTS' );
}
?>