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 AND `album` != '%s' AND `album` != '%s' ",
40 dbesc('Contact Photos'),
41 dbesc( t('Contact Photos'))
44 function _map_folder1($el){return array(bin2hex($el['album']),$el['album']);};
45 $albums = array_map( "_map_folder1" , $albums);
51 $album = hex2bin($a->argv[2]);
52 $sql_extra = sprintf("AND `album` = '%s' ",dbesc($album));
54 $path[]=array($a->argv[2], $album);
57 $r = q("SELECT `resource-id`, `id`, `filename`, type, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `desc`
58 FROM `photo` WHERE `uid` = %d $sql_extra AND `album` != '%s' AND `album` != '%s'
59 GROUP BY `resource-id` $sql_extra2",
61 dbesc('Contact Photos'),
62 dbesc( t('Contact Photos'))
65 function _map_files1($rr){
67 $types = Photo::supportedTypes();
68 $ext = $types[$rr['type']];
70 if($a->theme['template_engine'] === 'internal') {
71 $filename_e = template_escape($rr['filename']);
74 $filename_e = $rr['filename'];
78 $a->get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
80 $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.'. $ext
83 $files = array_map("_map_files1", $r);
85 $tpl = get_markup_template($template_file);
87 $o = replace_macros($tpl, array(
89 '$baseurl' => $a->get_baseurl(),
91 '$folders' => $albums,
93 '$cancel' => t('Cancel'),
94 '$nickname' => $a->user['nickname'],
101 $files = q("SELECT `id`, `filename`, `filetype` FROM `attach` WHERE `uid` = %d ",
105 function _map_files2($rr){ global $a;
106 list($m1,$m2) = explode("/",$rr['filetype']);
107 $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
109 if($a->theme['template_engine'] === 'internal') {
110 $filename_e = template_escape($rr['filename']);
113 $filename_e = $rr['filename'];
116 return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
118 $files = array_map("_map_files2", $files);
121 $tpl = get_markup_template($template_file);
122 $o = replace_macros($tpl, array(
124 '$baseurl' => $a->get_baseurl(),
125 '$path' => array( array( "", t("Files")) ),
128 '$cancel' => t('Cancel'),
129 '$nickname' => $a->user['nickname'],
137 if (x($_GET,'mode')) {