(1) $\langle z | z \rangle =1$ and $\langle z | z' \rangle =0$
forif $z,z' \in B$ and $z\neq z'$, i.e. $B$ is an orthonormal system;
Identities like this:
$$ \sum_n \phi_n(x) \phi_n^*(x') = \frac{1}{w(x)}\delta(x-x') \,.$$
stay for the completeness property of a Hilbert basis in $L^2(X, w(x)dx)$: a formal version of (4) above.
However such an identity is completely formal and, in general it does not hold if $\{\phi_n\}$ is aha Hilbert basis of $L^2(X, w(x)dx)$ (also because the value of $\phi_n$ at $x$ does not make any sense in $L^2$ spaces, as its elements are defined up to zero measurwemeasure sets and $\{x\}$ has zero measure). That identity sometime holds rigorously if (1) the functions $\phi_n$ are sufficiently regular and (2) the identity is understood in distributional sense, working with suitably smooth test functions like ${\cal S}(\mathbb R)$ in $\mathbb R$.
In $L^2(\mathbb R, d^nx)$ spaces all Hilbert bases are countable. Think of the basis of eigenvectors of the Hamiltonian operator of an Harmonic oscillator in $L^2(\mathbb R)$ (in $\mathbb R^n$ one may use a $n$ dimensional harmonic oscillator). However, essentially for for practical computations it is convenient also speaking of formal eigenvectors of, for example, the position operator: $|x\rangle$. In this case, $x \in \mathbb R$ so it could seem that $L^2(\mathbb R)$ admits also uncountable bases. It is false! $\{|x\rangle\}_{x\in \mathbb R}$ is not an orthonormal basis. It is just a formal object, (very) useful in computations.
If you want to make rigorous these objects, you should picture the space of the states as a direct integral over $\mathbb R$ of finite dimensional spaces $\mathbb C$, or as a rigged Hilbert space. In both cases however $\{|x\rangle\}_{x\in \mathbb R}$ is not an orthonormal Hilbertian basis. And $|x\rangle$ does not belong to $L^2(\mathbb R)$.
Hilbert bases are not enough to state and prove the spectral decomposition theorem for normal operators in a complex Hilbert space. Normal operators $A$ are those verifying $AA^\dagger= A^\dagger A$, unitary and self-adjoint ones are particular cases.
The notion of Hilbert basis is however enough for stating the said theorem for normal compact operators or normal operators whose resolvent is compact. In that case, the spectrum is a pure point spectrum (with only a possible point in the continuous part of the spectrum). It happens, for example, for the Hamiltonian operator of the harmonic oscillator. In general one has to introduce the notion of spectral measure or PVM (projector valued measure) to treat the general case.