<?php if (!defined('HTTP_SERVER')) die('You can not access this file directly!');
/**
  @licence GPL 2005-2010  The osCSS developers - osCSS Open Source E-commerce
  @portion code Copyright (c) 2002 osCommerce
  @package osCSS-2 <www http://www.oscss.org>
  @version 2.0.9
  @date  16/07/10, 20:58
  @author oscim <mail aurelien@oscim.fr> <www http://www.oscim.fr>
  @encode UTF-8
  @class dataTableInnerHTML

  gestion des dataTable via ajax, tri, search
*/

class dataTableInnerHTML {

  /**
    @p string type (products/categories/etc...)
  */
  public static $type;
  /**
    @p string mode (page|content)
  */
  public static $mode;
  /**
    @p array modele tableau des col dispo pour search
  */
  public static $modele;
  /**
    @p array list tableau
  */
  public static $list;
  /**
    @p int page index page num
  */
  public static $page=1;
  /**
    @p int rowbyp filtre nombre lg
  */
  public static $rowbyp;
  /**
    @p string sOrder clause order
  */
  public static $sOrder= '';
  /**
    @p string sWhere clause where supp
  */
  public static $sWhere= '';

  public function __construct(){
    global $language;

    if(!isset($_GET['type'])) return false;

    self::$type= $_GET['type'];
    self::$mode= (isset($_GET['mod']))?$_GET['mod']:'content';
    self::$page=$_GET['iDisplayStart'] / $_GET['iDisplayLength'];
    self::$rowbyp=(isset($_GET['iDisplayLength'])?$_GET['iDisplayLength'] : MAX_DISPLAY_ROW_BY_PAGE );

    $function='init_mod_'.self::$mode;
    self::$function();




  }



  /**
    View detail row in the table , via Datatable
  */
  public function display_view(){
    switch($_GET['action']){
      case 'detail':
      default:
	$function='detail_row_'.self::$mode;
	echo self::$function($_GET['ID']);
    }
    exit;
  }


  /**
    Init class soutient
  */
  private function init_mod_page(){
    $obj=self::$type;
    $oscss=oscss_cstr::getInstance();

    $oscss->pile_file_lang(DIR_WS_LANGUAGES . $oscss->the_var('language') . '/modules/pages/'.self::$type.'.txt');
    include (DIR_WS_FUNCTIONS.'lib.'.self::$type.'.php');

    require(DIR_WS_MODULES.'pages/'.$obj.'.php');

    self::$modele=call_user_func(array($obj, 'tep_get_modele'));


  }

  private function detail_row_page($id){
    //! data array list
    return call_user_func(array(self::$type, 'detail_row_page'),$id);
  }

  /**
    Init libs functions  soutient
  */
//   private function init_mod_content(){
//
//     include (DIR_WS_FUNCTIONS.'lib.'.self::$type.'.php');
//     include (DIR_WS_LANGUAGES.$language.'/'.self::$type.'.php');
//
//     //! tableau modele col data
//     $funct='tep_get_modele_'.self::$type;
//     self::$modele=$funct();
//
//   }

  private function list_mod_content(){
    //! data array list
    $funct='tep_get_list_'.self::$type;
    self::$list=$funct(0,self::$page,self::$rowbyp,self::$sOrder,self::$sWhere);
  }

}

?>