#!/bin/bash
docdir=$(ls -d1 php-??)
kdedir=`kde-config --prefix`

if test -z "$kdedir"; then
 kdedir=$KDEDIR
 if ! test -n "$KDEDIR";then
   kdedir="/opt/kde3"
 fi
 kdehome=$KDEHOME
 if ! test -n "$KDEHOME" ;then
    kdehome="~/.kde"
 fi
fi

echo "===================================================================="
echo " This script installs the PHP documentaion for Quanta+ into the "
echo " global ($kdedir/share/apps/quanta/doc/$docdir) or"
echo " local  ($kdehome/share/apps/quanta/doc/$docdir) documentation"
echo " directory, depending if root or a regular user runs the script."
echo "===================================================================="
echo

if  [ `id -u` = 0 ]; then

  kde_dir=`kde-config --prefix`

  if test -z "$kde_dir"; then
   kde_dir="/opt/kde"
  fi

  if test -n "$KDEDIR";then
    kde_dir="$KDEDIR"
  fi
else

  kde_dir=~/.kde
  
  if test -n "$KDEHOME" ;then
    kde_dir="$KDEHOME"
  fi
fi

echo "Install dir [${kde_dir}/share/apps/quanta/doc]:"
read newdir
if [ "$newdir"a = a ]; then newdir="${kde_dir}/share/apps/quanta/doc"; fi
echo "$newdir"
if ! test -d "$newdir"
then 
 mkdir $newdir
fi
cp -R $docdir $docdir.docrc "$newdir" && echo "done"
