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 //echo "<pre>"; var_dump($a->argv); killme();
25 $path = array( array($a->get_baseurl()."/fbrowser/image/", t("Photos")));
28 $sql_extra2 = " ORDER BY created DESC LIMIT 0, 10";
31 $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d ",
34 // anon functions only from 5.3.0... meglio tardi che mai..
35 function folder1($el){return array(bin2hex($el['album']),$el['album']);}
36 $albums = array_map( "folder1" , $albums);
42 $album = hex2bin($a->argv[2]);
43 $sql_extra = sprintf("AND `album` = '%s' ",dbesc($album));
45 $path[]=array($a->get_baseurl()."/fbrowser/image/".$a->argv[2]."/", $album);
48 $r = q("SELECT `resource-id`, `id`, `filename`, type, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `desc`
49 FROM `photo` WHERE `uid` = %d AND (height <= 320 AND width <= 320) $sql_extra
50 GROUP BY `resource-id` $sql_extra2",
56 $types = Photo::supportedTypes();
57 $ext = $types[$rr['type']];
59 if($a->theme['template_engine'] === 'internal') {
60 $filename_e = template_escape($rr['filename']);
63 $filename_e = $rr['filename'];
67 $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['hiq'] . '.' .$ext,
69 $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.'. $ext
72 $files = array_map("files1", $r);
74 $tpl = get_markup_template("filebrowser.tpl");
75 echo replace_macros($tpl, array(
77 '$baseurl' => $a->get_baseurl(),
79 '$folders' => $albums,
81 '$cancel' => t('Cancel'),
88 $files = q("SELECT id, filename, filetype FROM `attach` WHERE `uid` = %d ",
92 function files2($rr){ global $a;
93 list($m1,$m2) = explode("/",$rr['filetype']);
94 $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
96 if($a->theme['template_engine'] === 'internal') {
97 $filename_e = template_escape($rr['filename']);
100 $filename_e = $rr['filename'];
103 return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
105 $files = array_map("files2", $files);
106 //echo "<pre>"; var_dump($files); killme();
109 $tpl = get_markup_template("filebrowser.tpl");
110 echo replace_macros($tpl, array(
112 '$baseurl' => $a->get_baseurl(),
113 '$path' => array( array($a->get_baseurl()."/fbrowser/image/", t("Files")) ),
116 '$cancel' => t('Cancel'),