Beispiel #1
0
 function load($name, $type = "core")
 {
     static $loaded;
     $name = strtolower($name);
     $type = empty($type) ? "core" : $type;
     if (isset($loaded[$type][$name])) {
         return $loaded[$type][$name];
     }
     if (class_exists($name)) {
         return true;
     }
     $isloaded = false;
     switch ($type) {
         case "framework":
             $isloaded = XoopsLoad::loadFramework($name);
             break;
         case "class":
         case "core":
             $type = "core";
             $isloaded = XoopsLoad::loadCore($name);
             break;
         default:
             $isloaded = XoopsLoad::loadModule($name, $type);
             break;
     }
     $loaded[$type][$name] = $isloaded;
     return $loaded[$type][$name];
 }
Beispiel #2
0
 /**
  * @param        $name
  * @param string $type
  *
  * @return bool
  */
 static function load($name, $type = "core")
 {
     static $loaded;
     static $deprecated;
     if (!isset($deprecated)) {
         $deprecated = array('uploader' => 'xoopsmediauploader', 'utility' => 'xoopsutility', 'captcha' => 'xoopscaptcha', 'cache' => 'xoopscache', 'file' => 'xoopsfile', 'model' => 'xoopsmodelfactory', 'calendar' => 'xoopscalendar', 'userutility' => 'xoopsuserutility');
     }
     $name = strtolower($name);
     if (in_array($type, array('core', 'class')) && array_key_exists($name, $deprecated)) {
         if (isset($GLOBALS['xoopsLogger'])) {
             $GLOBALS['xoopsLogger']->addDeprecated("xoops_load('{$name}') is deprecated, use xoops_load('{$deprecated[$name]}')");
         } else {
             trigger_error("xoops_load('{$name}') is deprecated, use xoops_load('{$deprecated[$name]}')", E_USER_WARNING);
         }
         $name = $deprecated[$name];
     }
     $type = empty($type) ? 'core' : $type;
     if (isset($loaded[$type][$name])) {
         return $loaded[$type][$name];
     }
     if (class_exists($name, false)) {
         $loaded[$type][$name] = true;
         return true;
     }
     $isloaded = false;
     switch ($type) {
         case 'framework':
             $isloaded = XoopsLoad::loadFramework($name);
             break;
         case 'class':
         case 'core':
             $type = 'core';
             $isloaded = XoopsLoad::loadCore($name);
             break;
         default:
             $isloaded = XoopsLoad::loadModule($name, $type);
             break;
     }
     $loaded[$type][$name] = $isloaded;
     return $loaded[$type][$name];
 }