<?php
/*
Copyright (C) 2008 by oscim   Project lossim  [ 15.09.2009, 09:17:59] @oscim
// kate: replace-trailing-space-save true; space-indent on; indent-width 2; mixedindent off; indent-mode cstyle; word-wrap-marker-color #41C2A4
ENCODE UTF-8
*/
/**
  Constructeur du nom des pages lors enregistrement des articles
  Speration et des rubrique, langue, nom, date ...

  @package lossim <web http://www.lossim.org>
  @author oscim <mail dom@oscim.fr > <web http://www.oscim.fr>
  @class doc_name

  NOTE:

*/
class doc_name extends db_posts{

  var $etat;
  /**
    @a string path+nom complet du fichier
  */
  function doc_name(){
  }


  /**

    @param
  array
    @a string titre:: le titre (champs)
    @a string type sys date (1,2,3)
    @a date date de publication mm-dd-yyyy
    @a date date de retrait des publication  mm-dd-yyyy
    @a string (P/I) Publié/Non publié
    @a string le path (champs)
  */
  /*public*/ function  init($array){
    global $cstr;
    $t=$cstr->_call('db_posts','the_post');
    $this->lang=(isset($array['choose_lg'])) ? $array['choose_lg'] : ( isset($t['lang'])? $t['lang'] : LANG_POST) ;
    $this->bak_name=(isset($t['nom_ss_ext']) && tep_not_null($t['nom_ss_ext']))? $t['nom_ss_ext'] : 'bak_tmp';
    $this->bak_chemin=(isset($t['chemin'])&& tep_not_null($t['chemin']))? $t['chemin'] : ADD_PATH_ADMIN.REP_DATA.$this->lang.'/';
    $this->bak_rub=(isset($t['rub']))? $t['rub'] : '';
    $this->ext=(isset($t['ext'])&& tep_not_null($t['ext']))? $t['ext'] : 'xml';
    $this->bak_key = md5($this->bak_rub.$this->bak_name);
    $this->new_titre=@$array['titre_page'];
    $this->new_name= (isset($array['chemin_page']) && !empty($array['chemin_page']) && !eregi('bak_tmp',$array['chemin_page']))? clean_for_name_files(eregi_replace('(.*/)*','',$array['chemin_page'])) : clean_for_name_files (@$array['titre_page']);
    $this->Addtype(@$array['date_publi'],@$array['date_retrait']);
    $this->Addactif(@$array['etat_page']);
    $this->Addrub(@$array['file_rep']);

    return $this;
  }


  /**
   Ajout Contrainte de dates
  */
  /*private*/ function Addtype($d_publi,$d_retrait){
    $this->d_publi=false;
    $this->d_retrait=false ;
    if (tep_not_null($d_publi) && $d_publi !='--') $this->d_publi = $d_publi;
    if (tep_not_null($d_retrait)  && $d_retrait !='--') $this->d_retrait = $d_retrait;
  }


  /** Ajout type  ( publi / Non publi) */
  /*private*/ function Addactif($actif){
    if (strtoupper($actif) == "P") $this->etat="true";
    elseif(strtoupper($actif) == "I") $this->etat="false";
    else $this->etat="false";
  }


  /**
    Add new path
  */
  /*private*/ function Addrub($chemin){
    if (empty($chemin)) $chemin=$this->bak_chemin;
      $t=NewFct('extract_nom_dater_evoluer',ADD_PATH_ADMIN.REP_DATA.$chemin.'/test.'.$this->ext,"");
      $this->new_chemin = ADD_PATH_ADMIN.REP_DATA.(tep_not_null($t['lang'])?$t['lang']:$this->lang).'/'.$t['rub'];
      $this->new_rub=$t['rub'];
  }


  /**
    Retour element object
  */
  /*public*/ function the_new_obj(){
     return $this;
  }


  /**
   */
  /*public*/ function New_name(){
    $this->new_key = md5($this->new_rub.$this->new_name);
    return $this->new_name;
  }

  /**
  */
  /*public*/ function debugg(){
    print_r($this);
  }
}
?>