Esempio n. 1
0
 /**
  * Load current frontend class.
  *
  * @param string $uiclass Name of class implementing the frontend
  *
  * @return object the frontend object, or a PEAR error
  * @static
  */
 function &setFrontendClass($uiclass)
 {
     if (is_object($GLOBALS['_PEAR_Command_uiobject']) && is_a($GLOBALS['_PEAR_Command_uiobject'], $uiclass)) {
         return $GLOBALS['_PEAR_Command_uiobject'];
     }
     if (!class_exists($uiclass)) {
         $file = str_replace('_', '/', $uiclass) . '.php';
         if (PEAR_Command::isIncludeable($file)) {
             include_once $file;
         }
     }
     if (class_exists($uiclass)) {
         $obj =& new $uiclass();
         // quick test to see if this class implements a few of the most
         // important frontend methods
         if (method_exists($obj, 'userConfirm')) {
             $GLOBALS['_PEAR_Command_uiobject'] =& $obj;
             $GLOBALS['_PEAR_Command_uiclass'] = $uiclass;
             return $obj;
         } else {
             $err = PEAR::raiseError("not a frontend class: {$uiclass}");
             return $err;
         }
     }
     $err = PEAR::raiseError("no such class: {$uiclass}");
     return $err;
 }