#!/bin/sh

#   Libray       : Dilib
#   Module       : Explor
#   Commande     : ExplorAreaRestart
#   Author       : Ducloy
#   Date         : Aout 2020
#   Version      : V0.6.35

USAGE="usage: ExplorAreaRestart [-l level] " 

LEVEL=3

while getopts l: c
do
  case $c in
  l) LEVEL=$OPTARG
  ;;
  \?) echo -$c $OPTARG unknowed option
       echo $USAGE
       exit 2;;
  esac
done

if [ $LEVEL -eq "3" ]
then
sh $EXPLOR_AREA/bin/AreaReset.sh
ExplorAreaDataCreate -d $EXPLOR_AREA
make -f $EXPLOR_AREA/bin/area.mk
sh $EXPLOR_AREA/bin/AreaCreateSite.fr.sh
fi

if [ $LEVEL -eq "2" ]
then
sh $EXPLOR_AREA/bin/AreaResetSite.sh
sh $EXPLOR_AREA/bin/AreaCreateSite.fr.sh
fi

cat $EXPLOR_AREA/Import/ListKeys.wiki       \
  |  MediaWikiCleanTable                     \
  | MediaWikiTable2SxmlRowCol                \
  | MediaWikiTableTransformCol -t 123 -T 4   \
  > $EXPLOR_AREA/Input/ListKeys.xml

MediaWikiExportCommand -c fileBegin > $EXPLOR_AREA/exportTemplates.xml
ExplorGenerTemplateSize -f $EXPLOR_AREA/Input/ListKeys.xml -p >> $EXPLOR_AREA/exportTemplates.xml
source $EXPLOR_AREA/FixBin/AreaGenerWikiTemplateMaps.sh >> $EXPLOR_AREA/exportTemplates.xml
source $EXPLOR_AREA/FixBin/AreaGenerWikiTemplateInclude.sh >> $EXPLOR_AREA/exportTemplates.xml
MediaWikiExportCommand -c fileEnd >> $EXPLOR_AREA/exportTemplates.xml

