/** @brief Add a directory to be searched for matching class names/files. Directories added here are searched for matching classfiles using patterns from the types array. The direcctory path starts from WB_PATH(webroot). The defautl patters in WB is class.classname.php all lowercase letters. @code WbAuto::AddDir("/classes/"); WbAuto::AddDir("/modules/mymodule/classes/"); WbAuto::AddDir("/var/web345/html/websitebaker/modules/mymodule/classes/" ,true); @endcode @note Autodetection for direct path added , so in most cases you no longer need the direct path parameter. @param string $Dir The path to the Directory to include starting from WB_PATH @param bool $Dir if set to true WB_PATH is not added @param boolean $DirektPath Set to true to add a direkt path whithout added WB_PATH @retval boolean/string Returns false on success, and an error message on failure. */ public static function AddDir($Dir = "", $DirektPath = false) { // some checks if (!is_string($Dir)) { return "AddDir: Directory needs to be a string."; } if (empty($Dir)) { return "AddDir: Directory is empty."; } // for windooze make sure we got the right seperator $Dir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $Dir); //always trim and re-add so we make sure we have a seperator at the end $Dir = rtrim($Dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; // allow to add dirs directly if (strpos($Dir, WB_PATH) !== FALSE || $DirektPath) { //construct full dir whithout WB path $AddDir = $Dir; } else { //construct full dir whith WB path $AddDir = WB_PATH . "/" . $Dir; } //Some more checks if (!is_dir($AddDir)) { return "AddDir: Not a directory using is_dir: {$AddDir}"; } if (!is_readable($AddDir)) { return "AddDir: Directory not readable: {$AddDir}"; } // Add Dir WbAuto::$Dirs[] = $AddDir; //avoid double entries WbAuto::$Dirs = array_unique(WbAuto::$Dirs); return false; }
static function AddDir($Dir) { // for windooze $Dir = str_replace("\\", "/", $Dir); //always trim at front end end $Dir = trim($Dir, "/"); //construct full dir $AddDir = WB_PATH . "/" . $Dir . "/"; //Some checks if (!is_dir($AddDir)) { return "Not a directory: {$AddDir}"; } if (!is_readable($AddDir)) { return "Directory not readable: {$AddDir}"; } // Add Dir WbAuto::$Dirs[] = $AddDir; //avoid double entries WbAuto::$Dirs = array_unique(WbAuto::$Dirs); return FALSE; }