3 * @package Friendica\modules
4 * @subpackage FileBrowser
5 * @author Fabio Comuni <fabrixxm@kirgroup.com>
8 require_once('include/Photo.php');
13 if(! function_exists('fbrowser_content')) {
14 function fbrowser_content($a){
22 $template_file = "filebrowser.tpl";
24 if (x($_GET,'mode')) {
25 $template_file = "filebrowser_plain.tpl";
26 $mode = "?mode=".$_GET['mode'];
29 //echo "<pre>"; var_dump($a->argv); killme();
33 $path = array( array("", t("Photos")));
36 $sql_extra2 = " ORDER BY created DESC LIMIT 0, 10";
39 $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' ",
41 dbesc('Contact Photos'),
42 dbesc( t('Contact Photos'))
45 function _map_folder1($el){return array(bin2hex($el['album']),$el['album']);};
46 $albums = array_map( "_map_folder1" , $albums);
52 $album = hex2bin($a->argv[2]);
53 $sql_extra = sprintf("AND `album` = '%s' ",dbesc($album));
55 $path[]=array($a->argv[2], $album);
58 $r = q("SELECT `resource-id`, `id`, `filename`, type, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `desc`
59 FROM `photo` WHERE `uid` = %d $sql_extra AND `album` != '%s' AND `album` != '%s'
60 GROUP BY `resource-id` $sql_extra2",
62 dbesc('Contact Photos'),
63 dbesc( t('Contact Photos'))
66 function _map_files1($rr){
68 $types = Photo::supportedTypes();
69 $ext = $types[$rr['type']];
71 if($a->theme['template_engine'] === 'internal') {
72 $filename_e = template_escape($rr['filename']);
75 $filename_e = $rr['filename'];
79 $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
81 $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.'. $ext
84 $files = array_map("_map_files1", $r);
86 $tpl = get_markup_template($template_file);
88 $o = replace_macros($tpl, array(
90 '$baseurl' => $a->get_baseurl(),
92 '$folders' => $albums,
94 '$cancel' => t('Cancel'),
95 '$nickname' => $a->user['nickname'],
102 $files = q("SELECT `id`, `filename`, `filetype` FROM `attach` WHERE `uid` = %d ",
106 function _map_files2($rr){ global $a;
107 list($m1,$m2) = explode("/",$rr['filetype']);
108 $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
110 if($a->theme['template_engine'] === 'internal') {
111 $filename_e = template_escape($rr['filename']);
114 $filename_e = $rr['filename'];
117 return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
119 $files = array_map("_map_files2", $files);
122 $tpl = get_markup_template($template_file);
123 $o = replace_macros($tpl, array(
125 '$baseurl' => $a->get_baseurl(),
126 '$path' => array( array( "", t("Files")) ),
129 '$cancel' => t('Cancel'),
130 '$nickname' => $a->user['nickname'],
138 if (x($_GET,'mode')) {