'See citadel.py::ImportHandler.find_importables_in_dir() for
details.
Importables for PHP look like this:
{"foo.php": ("foo.php", None, False),
"bar.inc": ("bar.inc", None, False),
"somedir": (None,      None, True)}
TODO: log the fs-stat\'ing a la codeintel.db logging.'

def find_importables_in_dir(self, dir):

    from os.path import join, isdir
    from fnmatch import fnmatch
    if (dir == '<Unsaved>'):
        return {}
    try:
        names = os.listdir(dir)
    except OSError as ex:
        return {}
    (dirs, nondirs) = (set(), set())
    for name in names:
        try:
            if isdir(join(dir, name)):
                dirs.add(name)
            else:
                nondirs.add(name)
        except UnicodeDecodeError:
            pass
    importables = {}
    patterns = self.mgr.env.assoc_patterns_from_lang('PHP')
    for name in nondirs:
        for pattern in patterns:
            if fnmatch(name, pattern):
                break
        else:
            continue
        if (name in dirs):
            importables[name] = (name, None, True)
            dirs.remove(name)
        else:
            importables[name] = (name, None, False)
    for name in dirs:
        importables[name] = (None, None, True)
    return importables
