Ext.define("Portfolio.registry.tree.proxy.Registry", {

	extend: "Ext.data.proxy.Ajax",

	alias: "proxy.registry",

	alternateClassName: [
		"Ext.registry.tree.proxy.Registry"
	],

	constructor: function (o_config) {

		var i_proxy = this;

		var o_proxy = Ext.apply({}, o_config);

		var o_reader = {
			type: 'json',
			$configStrict: false,
			paramsAsJson: true,
			getData: function(a_records) {

				Ext.Array.each(a_records, function(o_record) {
					var o_meta = o_record.meta || {
						properties: {},
						plugin: {
							src: ""
						}
					};
					o_record.meta = o_meta;
					if (!o_meta.properties) {
						o_meta.properties = Ext.apply({}, o_meta);
					}
					if (!o_meta.plugin) {
						o_meta.plugin = {
							src: ""
						};
					}
					var o_properties = o_meta.properties;
					if (o_properties.title) {
						Ext.apply(o_record, {
							text: ip2.i18n(o_properties.title)
						});
					}
					else {
						var s_text = o_record.key.split(".").pop();
						s_text = s_text.charAt(0) + s_text.slice(1);
						Ext.apply(o_record, {
							text: s_text
						});
					}
					if (!o_record.haschildren) {
						Ext.apply(o_record, {
							loaded: true
						});
					}
					delete o_record.id;
				});
				return a_records;
			}
		};

		Ext.apply(o_proxy, {
			reader: o_reader
		});

		i_proxy.callParent([o_proxy]);

		return i_proxy;
	}
});
