<?xml version="1.0" encoding="UTF-8"?>
<uploader enabled="false" text="51" title="132" order="10" id="uploader.http" label="CONF_MESSAGE[Remote Download]"
          description="CONF_MESSAGE[Async downloader to load a file from another source]"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
	<class_definition filename="plugins/uploader.http/HttpDownload.php" classname="Pydio\Uploader\Processor\HttpDownload"/>
	<client_settings>
		<resources>
			<js file="plugins/uploader.http/js/build/UploaderView.js" className="HTTPUploaderView" depends="React"/>
	        <i18n namespace="httpdownloader" path="plugins/uploader.http/resources/i18n" />
            <css file="plugins/uploader.http/resources/downloader.css" autoload="true"/>
		</resources>
	</client_settings>
	<registry_contributions>
        <extensions>
            <extension mime="download" messageId="httpdownloader.17" font="cloud-download" icon="httpdownloader_images/ICON_SIZE/kget_list.png"/>
            <extension mime="dlpart" messageId="httpdownloader.18" font="file-import" icon="exe.png"/>
        </extensions>
		<actions>
            <action name="external_download">
				<gui text="httpdownloader.1" title="httpdownloader.2" src="httpdownloader_images/ICON_SIZE/external_download.png" accessKey="httpdownloader.3" hasAccessKey="true">
					<context selection="false" dir="true" recycle="hidden"
						actionBar="false" contextMenu="false" infoPanel="false"
						actionBarGroup="put" inZip="false">
					</context>
				</gui>
				<rightsContext noUser="true" userLogged="only" read="false" write="true" adminOnly=""/>
				<processing>
					<serverCallback methodName="switchAction"/>
				</processing>
			</action>
			<action name="generate_dl_bookmarklet">
				<gui text="httpdownloader.9" title="httpdownloader.9" iconClass="icon-bookmark" src="httpdownloader_images/ICON_SIZE/add_bookmarklet.png" accessKey="httpdownloader.3" hasAccessKey="false">
					<context selection="false" dir="true" recycle="hidden"
						actionBar="false" contextMenu="false" infoPanel="false"
						actionBarGroup="other" inZip="false">
					</context>
				</gui>
				<rightsContext noUser="true" userLogged="only" read="false" write="true" adminOnly=""/>
				<processing>
					<clientCallback dialogOpenForm="dynamic_bookmarklet">
						<dialogOnOpen><![CDATA[
						    var rm =new ResourcesManager();
						    rm.loadCSSResource('plugins/uploader.http/resources/downloader.css');
							var root = document.location.href;
							root = root.substring(0,root.lastIndexOf("/") + 1);
							var repository = ajaxplorer.user.getActiveRepository();
							var folder = ajaxplorer.getContextNode().getPath();
							var bmletValue = "javascript:(function(){window.ajxp_bm_target='"+root+"',window.ajxp_bm_repository_id='"+repository+"', window.ajxp_bm_folder='"+folder+"'; var d=document,s=d.createElement('scr'+'ipt'),b=d.body,l=d.location;s.setAttribute('src','"+root+"plugins/uploader.http/bookmarklet/ajxp.js?t='+(new Date().getTime()));b.appendChild(s)})();";
							$('bookmarklet_link').setAttribute("href", bmletValue);
							var basename = getBaseName(folder);
							if(basename == ""){
                                $('bookmarklet_link_a').hide();
                                $('bookmarklet_link_d').hide();
                                $('bookmarklet_link_c').hide();
							}else{
                                $('bookmarklet_link_a').setAttribute("href", bmletValue);
                                $('bookmarklet_link_a').insert(MessageHash['httpdownloader.10a'].replace("%s", basename));

                                $('bookmarklet_link_c').setAttribute("href", bmletValue);
                                $('bookmarklet_link_c').insert(MessageHash['httpdownloader.10c'].replace("%s", basename));

                                $('bookmarklet_link_d').setAttribute("href", bmletValue);
                                $('bookmarklet_link_d').insert(MessageHash['httpdownloader.10d'].replace("%s", basename));
                            }

                            $('bookmarklet_link_b').setAttribute("href", bmletValue);
                            $('bookmarklet_link_b').insert(MessageHash['httpdownloader.10b'].replace("%s", ajaxplorer.user.repositories.get(repository).getLabel()));
                            $('bookmarklet_links_container').select('a').each(function(link){
                                link.observe('click', function(e){Event.stop(e);alert(MessageHash['httpdownloader.16']);});
                            });

							$('bookmarklet_textarea').setValue(bmletValue);
							$('bookmarklet_textarea').observe("focus", function(){$('bookmarklet_textarea').select();});

						]]></dialogOnOpen>
					</clientCallback>
					<clientForm id="dynamic_bookmarklet"><![CDATA[
					<div id="dynamic_bookmarklet" box_width="400">
					    <div>AJXP_MESSAGE[httpdownloader.11]</div>
					    <div id="bookmarklet_links_container" style="width:400px;">
                            <a href="" id="bookmarklet_link" title="AJXP_MESSAGE[httpdownloader.10]"  alt="AJXP_MESSAGE[httpdownloader.10]">AJXP_MESSAGE[httpdownloader.10]</a>
                            <a href="" id="bookmarklet_link_a" title="AJXP_MESSAGE[httpdownloader.10]"  alt="AJXP_MESSAGE[httpdownloader.10]"></a>
                            <a href="" id="bookmarklet_link_b" title="AJXP_MESSAGE[httpdownloader.10]"  alt="AJXP_MESSAGE[httpdownloader.10]"></a>
                            <a href="" id="bookmarklet_link_c" title="AJXP_MESSAGE[httpdownloader.10]"  alt="AJXP_MESSAGE[httpdownloader.10]"></a>
                            <a href="" id="bookmarklet_link_d" title="AJXP_MESSAGE[httpdownloader.10]"  alt="AJXP_MESSAGE[httpdownloader.10]"></a>
						</div>
						<div style="clear:left;">AJXP_MESSAGE[httpdownloader.15]</div>
						<textarea id="bookmarklet_textarea" style="width: 100%;margin-top: 4px;height: 140px;"></textarea>
					</div>
					]]></clientForm>
				</processing>
			</action>
			<action name="update_dl_data">
				<processing>
					<serverCallback methodName="switchAction"/>
				</processing>
			</action>
			<action name="stop_dl">
				<processing>
					<serverCallback methodName="switchAction"/>
				</processing>
			</action>
		</actions>
		<hooks>
			<serverCallback hookName="node.info" methodName="detectDLParts"></serverCallback>
		</hooks>
	</registry_contributions>
	<dependencies>
		<!-- Stream Wrapper Access -->
		<activePlugin pluginName="access.AJXP_STREAM_PROVIDER"/>
	</dependencies>
    <processing>
		<clientForm module="HTTPUploaderView.Uploader"/>
        <serverCallback methodName="switchAction"></serverCallback>
    </processing>
</uploader>
