3 * @package Friendica\modules
4 * @subpackage FileBrowser
5 * @author Fabio Comuni <fabrixxm@kirgroup.com>
8 require_once('include/Photo.php');
13 function fbrowser_content($a){
21 $template_file = "filebrowser.tpl";
23 if (x($_GET,'mode')) {
24 $template_file = "filebrowser_plain.tpl";
25 $mode = "?mode=".$_GET['mode'];
28 //echo "<pre>"; var_dump($a->argv); killme();
32 $path = array( array("", t("Photos")));
35 $sql_extra2 = " ORDER BY created DESC LIMIT 0, 10";
38 $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d ",
41 // anon functions only from 5.3.0... meglio tardi che mai..
42 $folder1 = function($el) use ($mode) {return array(bin2hex($el['album']),$el['album']);};
43 $albums = array_map( $folder1 , $albums);
49 $album = hex2bin($a->argv[2]);
50 $sql_extra = sprintf("AND `album` = '%s' ",dbesc($album));
52 $path[]=array($a->argv[2], $album);
55 $r = q("SELECT `resource-id`, `id`, `filename`, type, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `desc`
56 FROM `photo` WHERE `uid` = %d $sql_extra
57 GROUP BY `resource-id` $sql_extra2",
63 $types = Photo::supportedTypes();
64 $ext = $types[$rr['type']];
66 if($a->theme['template_engine'] === 'internal') {
67 $filename_e = template_escape($rr['filename']);
70 $filename_e = $rr['filename'];
74 $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '.' .$ext,
76 $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.'. $ext
79 $files = array_map("files1", $r);
81 $tpl = get_markup_template($template_file);
83 $o = replace_macros($tpl, array(
85 '$baseurl' => $a->get_baseurl(),
87 '$folders' => $albums,
89 '$cancel' => t('Cancel'),
90 '$nickname' => $a->user['nickname'],
97 $files = q("SELECT id, filename, filetype FROM `attach` WHERE `uid` = %d ",
101 function files2($rr){ global $a;
102 list($m1,$m2) = explode("/",$rr['filetype']);
103 $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
105 if($a->theme['template_engine'] === 'internal') {
106 $filename_e = template_escape($rr['filename']);
109 $filename_e = $rr['filename'];
112 return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
114 $files = array_map("files2", $files);
115 //echo "<pre>"; var_dump($files); killme();
118 $tpl = get_markup_template($template_file);
119 $o = replace_macros($tpl, array(
121 '$baseurl' => $a->get_baseurl(),
122 '$path' => array( array( "", t("Files")) ),
125 '$cancel' => t('Cancel'),
126 '$nickname' => $a->user['nickname'],
134 if (x($_GET,'mode')) {