Logo Search packages:      
Sourcecode: dacode version File versions  Download package

libdacode.php3

<?php
/*
 * daCode http://www.dacode.org/
 * src/phplib/libdacode.php3
 * $Id: libdacode.php3,v 1.37.2.5 2002/05/15 17:27:04 jbcombes Exp $
 */


Function LoadClass($class,$opts="") {
      global $config;

      if ($class == 'Html') {
            $class .= $config->theme_name;
      }

      //   First checks whether user overloaded this class
      if (defined('_'.$class.'Local')) {
            $className = $class . 'Local';
      } elseif (!empty($config->overloads[$class])) {
            $className = $config->overloads[$class];
      } else {
            $className = $class;
      }
      if (!isset($config->obj[$class]) || !is_object($config->obj[$class])) {
            if (empty($opts)) {
                  $config->obj[$class] = new $className();
            } else {
                  //  Warning: Do not remove quotes within parens here,
                  //  otherwise it causes some memory leaks with PHP3
                  $config->obj[$class] = new $className("$opts");
            }
      }
      return $config->obj[$class];
}

/*
 * This setup the langage that should be used depending of the preferences of
 * the browser
 */

//   Preload classes used by all documents
$config->obj = array();
$db = LoadClass("Db");
$config->obj['Db'] = $db;
$session = LoadClass("Session");
$config->obj['Session'] = $session;

/*$row = split(', ',$HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'];);
$LANG="";
while(current($row)) {
      $cur = current($row);
      if (!empty($lang[$cur])) {
            $LANG   = $cur;
            break;
      }
      next($row);
}
if (empty($LANG))*/ $LANG = $config->defaultlang;

/* This is to activate the nospider */
if ($config->nospider) {
      $nospiderclass = new nospider();
      $nospiderclass->check();
}

//   Load Html derived classes for defined themes
reset($config->listofthemes);
while ($theme = each($config->listofthemes)) {
      $tmpl = $libdir."themes/".$theme[1]."/html.".$config->php;
      $tmpl_contrib = $libdir."themes/".$config->theme_subdir.$theme[1]."/html.".
            $config->php;
      if (file_exists($tmpl)) {
            include $tmpl;
      } elseif (file_exists($tmpl_contrib)) {
            include $tmpl_contrib;
      } else {
            $dft = $config->dft_prefs['theme'];
            include $libdir."themes/".$config->listofthemes[$dft]."/html.".
                  $config->php;
      }
}

//   ... and local extensions
if (file_exists($libdir.'local') &&
      is_dir($libdir.'local')) {
      $handle=opendir($libdir.'local');
      while ($file = readdir($handle)) {
            if (is_file($libdir.'local/'.$file) &&
                        ereg('\.'.$config->php.'$', $file)) {
                  include $libdir."local/".$file;
            }
      }
      closedir($handle);
}

?>

Generated by  Doxygen 1.6.0   Back to index