/** * Create and populate the file search * * @param array $paths. An array with keys file search categories * and values a path or an array of paths to add to the file * search * * @param boolean $clear_cache. Default to false. If true, we * clear out the APC Cache. */ public static function setupFileSearch($paths = array(), $clear_cache = false) { $db = MDB2::singleton(); if (!array_key_exists('HTTP_HOST', $_SERVER)) { //command line self::$fileSearch = new I2CE_FileSearch(FALSE, FALSE, TRUE); } else { self::$fileSearch = new I2CE_FileSearch_Caching(FALSE, FALSE, TRUE); self::$fileSearch->setPrefix($db->database_name); } self::$fileSearch->setPreferredLocales('MODULES', array(I2CE_Locales::DEFAULT_LOCALE)); self::$fileSearch->setPreferredLocales('CLASSES', array(I2CE_Locales::DEFAULT_LOCALE)); if ($clear_cache && function_exists('apc_clear_cache')) { apc_clear_cache('user'); } foreach ($paths as $cat => $path) { if (is_array($path)) { foreach ($path as $p) { self::$fileSearch->addPath($cat, $p); } } else { if (is_string($path)) { self::$fileSearch->addPath($cat, $path); } } } }