<?xml version='1.0' encoding='UTF-8'?><uidget><metadata><name>Download</name><description>Allow users to download a file</description><help>This block allows you to share documents (PDF, Word, archives, ...) with your visitors. It displays a customizable icon and possibly the file size and description (depending on the options you choose) which can be clicked in order to launch the file download. </help><api_version>1.0</api_version><size height='230' width='180' /><blog en='243' fr='242' /></metadata><view><content>&lt;div&gt;
	&lt;div class=&quot;uidl_img&quot;&gt;&lt;img src=&quot;&quot; border=0 /&gt;&lt;/div&gt;
	&lt;div class=&quot;uidl_sz&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;uidl_desc&quot;&gt;&lt;img src=&quot;/assets/icons/load.gif&quot;/&gt;&lt;/div&gt;
&lt;/div&gt;</content><properties><file_selector default_action='true' help='Select the file to download' icon='folder' name='file' value='Choose a file' /><checkbox default='true' help='If ticked, the download image will be related to the file type (note that this functionality only supports the most popular file extensions).' name='icon' value='Filetype icon' /><checkbox default='true' help='Display the file size in Bytes.' name='show_size' value='File size' /><checkbox default='false' help='Display the file description. You can add it in the file selector by changing the file properties.' name='show_desc' value='File description' /></properties></view><script>UI_List.UI_Download={initialize:function(a){this.cpt=a;
a.setOptions([&quot;locked&quot;])
},updateFile:function(){if(this.cpt.data.file){var a=this;
this.link.unbind().bind(&quot;click&quot;,function(){window.open(a.cpt.data.file.url.replace(&quot;/fs/&quot;,&quot;/dl/&quot;));
sigCtl.emit(&quot;UI_Download.download&quot;,a.cpt.data.file)
}).css(&quot;cursor&quot;,&quot;pointer&quot;);
this.sz.html(this.cpt.data.file.size)
}else{this.link.attr(&quot;href&quot;,&quot;&quot;).css(&quot;cursor&quot;,&quot;&quot;);
this.sz.html(&quot;&quot;);
this.desc.html(&quot;&quot;)
}},updateIcon:function(){this.icon_url=(this.cpt.data.file&amp;&amp;this.cpt.data.icon)?&quot;https://st0.cdnsw.com/file/icon/&quot;+(this.cpt.data.file.name.replace(/.*?([^.]*)$/,&quot;$1&quot;))+&quot;_&quot;+this.size:&quot;https://st0.cdnsw.com/assets/types/UI_Download/&quot;+this.size+&quot;.png&quot;;
this.img.attr(&quot;src&quot;,this.icon_url)
},updateDescription:function(){if(!this.cpt.data.file){return
}if(this.cpt.data.show_desc){var a=this;
FileDescription.get([this.cpt.data.file]).done(function(b){a.cpt.data.file.description=b[a.cpt.data.file.id];
if(!a.cpt.data.file.description){if(v.mode==&quot;editor&quot;){a.desc.html(&quot;File has no description yet. To add one: 1) click on &lt;i&gt;Choose a file&lt;/i&gt; 2) click on the magnifier of the file.&quot;).show()
}else{a.cpt.data.file.description=1
}}else{a.desc.html(a.cpt.data.file.description).show()
}})
}else{this.desc.hide()
}},onDisplay:function(a){this.link=a.find(&quot;div:first&quot;);
this.img=this.link.find(&quot;img&quot;);
this.desc=a.find(&quot;.uidl_desc&quot;);
this.sz=a.find(&quot;.uidl_sz&quot;);
this.name=a.find(&quot;.uidl_name&quot;);
this.onPropertyChanged([&quot;file&quot;,&quot;show_size&quot;])
},onPropertyChanged:function(a){if(a.include(&quot;file&quot;)){this.updateFile();
this.updateDescription();
this.onResize()
}if(a.include(&quot;icon&quot;)){this.updateIcon()
}if(a.include(&quot;show_size&quot;)){if(this.cpt.data.show_size){this.sz.show()
}else{this.sz.hide()
}}if(a.include(&quot;show_desc&quot;)){this.updateDescription()
}},onResize:function(){var a=Math.min(this.cpt.W(),this.cpt.H());
this.size=&quot;&quot;;
if(a&lt;=16){a=16;
this.size=16
}else{if(a&lt;=32){this.size=32
}else{if(a&lt;=64){this.size=64
}else{if(a&lt;=128){this.size=128
}else{a=128;
this.size=128
}}}}this.updateIcon();
this.img.width(a).height(a)
},onResizeStop:function(){}};</script><style>div.UI_Download .uidl_img{text-align:center}
div.UI_Download .uidl_sz{text-align:center;font-style:italic}
div.UI_Download .uidl_desc{display:none;text-align:center;font-size:12px;padding:2px;border:1px solid #000}</style></uidget>