MDL-46652 custom_menu: fix for multi-language support breaks menu nesting

Fixed bug by building full menu structure, then removing hidden menu items and all associated children.
Refactored custom_menu_item class and convert_text_to_menu_nodes() to improve maintenance.

Conflicts:
	lib/outputcomponents.php