| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
function photogallery_pagesetup() { |
|---|
| 4 |
} |
|---|
| 5 |
|
|---|
| 6 |
function photogallery_init() { |
|---|
| 7 |
|
|---|
| 8 |
global $CFG; |
|---|
| 9 |
$CFG->folders->handler["photogallery"]['menuitem'] = __gettext("Photo gallery"); |
|---|
| 10 |
$CFG->folders->handler["photogallery"]['view'] = "photogallery_folder_view"; |
|---|
| 11 |
$CFG->folders->handler["photogallery"]['preview'] = "photogallery_folder_preview"; |
|---|
| 12 |
|
|---|
| 13 |
} |
|---|
| 14 |
|
|---|
| 15 |
function photogallery_folder_view($folder) { |
|---|
| 16 |
|
|---|
| 17 |
global $CFG, $metatags, $messages; |
|---|
| 18 |
|
|---|
| 19 |
require_once($CFG->dirroot.'lib/filelib.php'); |
|---|
| 20 |
$metatags .= file_get_contents($CFG->dirroot . "mod/photogallery/css"); |
|---|
| 21 |
$metatags .= <<< END |
|---|
| 22 |
<script type="text/javascript"> |
|---|
| 23 |
var elggWwwRoot = "{$CFG->wwwroot}"; |
|---|
| 24 |
</script> |
|---|
| 25 |
<script type="text/javascript" src="{$CFG->wwwroot}mod/photogallery/lightbox/js/prototype.js"></script> |
|---|
| 26 |
<script type="text/javascript" src="{$CFG->wwwroot}mod/photogallery/lightbox/js/scriptaculous.js?load=effects"></script> |
|---|
| 27 |
<script type="text/javascript" src="{$CFG->wwwroot}mod/photogallery/lightbox/js/lightbox.js"></script> |
|---|
| 28 |
<link rel="stylesheet" href="{$CFG->wwwroot}mod/photogallery/lightbox/css/lightbox.css" type="text/css" media="screen" /> |
|---|
| 29 |
|
|---|
| 30 |
END; |
|---|
| 31 |
|
|---|
| 32 |
$file_html = ""; |
|---|
| 33 |
$photo_html = ""; |
|---|
| 34 |
$folder_html = ""; |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
if ($files = get_records_select('files',"folder = ? AND files_owner = ? ORDER BY time_uploaded desc",array($folder->ident,$folder->files_owner))) { |
|---|
| 40 |
|
|---|
| 41 |
foreach($files as $file) { |
|---|
| 42 |
|
|---|
| 43 |
if (run("users:access_level_check",$file->access) == true) { |
|---|
| 44 |
|
|---|
| 45 |
$image = $CFG->wwwroot . "_files/icon.php?id=" . $file->ident . "&w=200&h=200"; |
|---|
| 46 |
$filepath = $CFG->wwwroot . user_info("username",$file->files_owner) . "/files/$folder->ident/$file->ident/" . urlencode($file->originalname); |
|---|
| 47 |
$image = "<a href=\"{$CFG->wwwroot}_files/icon.php?id={$file->ident}&w=500&h=500\" rel=\"lightbox[folder]\"><img src=\"$image\" /></a>"; |
|---|
| 48 |
$fileinfo = round(($file->size / 1048576),4) . "Mb"; |
|---|
| 49 |
$filelinks = file_edit_links($file); |
|---|
| 50 |
$uploaded = sprintf(__gettext("Uploaded on %s"),strftime("%A, %d %B %Y",$file->time_uploaded)); |
|---|
| 51 |
$keywords = display_output_field(array("","keywords","file","file",$file->ident,$file->owner)); |
|---|
| 52 |
$mimetype = mimeinfo('type',$file->originalname); |
|---|
| 53 |
|
|---|
| 54 |
if (empty($file->title)) { |
|---|
| 55 |
$file->title = __gettext("No title"); |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
if (substr_count($mimetype, "image") > 0) { |
|---|
| 59 |
$photo_html .= <<< END |
|---|
| 60 |
|
|---|
| 61 |
<div class="photogallery-photo-container"> |
|---|
| 62 |
<div class="photogallery-photo-image"> |
|---|
| 63 |
$image |
|---|
| 64 |
</div> |
|---|
| 65 |
<div class="photogallery-photo-info"> |
|---|
| 66 |
<h2 class="photogallery-photo-title"><a href="$filepath" >{$file->title}</a></h2> |
|---|
| 67 |
<p class="photogallery-photo-description"> |
|---|
| 68 |
{$file->description} |
|---|
| 69 |
</p> |
|---|
| 70 |
<p class="photogallery-photo-keywords"> |
|---|
| 71 |
{$keywords} |
|---|
| 72 |
</p> |
|---|
| 73 |
<p class="photogallery-photo-infobar"> |
|---|
| 74 |
{$uploaded}<br /> |
|---|
| 75 |
{$fileinfo} {$mimetype} {$filelinks} |
|---|
| 76 |
</p> |
|---|
| 77 |
</div> |
|---|
| 78 |
</div> |
|---|
| 79 |
|
|---|
| 80 |
END; |
|---|
| 81 |
} else { |
|---|
| 82 |
$file_html .= <<< END |
|---|
| 83 |
|
|---|
| 84 |
<div class="photogallery-file-container"> |
|---|
| 85 |
<div class="photogallery-file-image"> |
|---|
| 86 |
<a href="{$filepath}">$image</a> |
|---|
| 87 |
</div> |
|---|
| 88 |
<div class="photogallery-file-info"> |
|---|
| 89 |
<h2 class="photogallery-file-title"><a href="{$filepath}">{$file->title}</a></h2> |
|---|
| 90 |
<p>{$file->description}</p> |
|---|
| 91 |
<p class="photogallery-file-keywords"> |
|---|
| 92 |
{$keywords} |
|---|
| 93 |
</p> |
|---|
| 94 |
<p class="photogallery-file-infobar"> |
|---|
| 95 |
{$uploaded}<br /> |
|---|
| 96 |
{$fileinfo} {$mimetype} {$filelinks} |
|---|
| 97 |
</p> |
|---|
| 98 |
</div> |
|---|
| 99 |
</div> |
|---|
| 100 |
|
|---|
| 101 |
END; |
|---|
| 102 |
} |
|---|
| 103 |
} |
|---|
| 104 |
} |
|---|
| 105 |
|
|---|
| 106 |
} |
|---|
| 107 |
|
|---|
| 108 |
if ($subfolders = get_records_select('file_folders',"parent = ? AND files_owner = ? ORDER BY name desc",array($folder->ident,$folder->owner))) { |
|---|
| 109 |
foreach($subfolders as $subfolder) { |
|---|
| 110 |
$folderlinks = file_folder_edit_links($subfolder); |
|---|
| 111 |
$keywords = display_output_field(array("","keywords","folder","folder",$subfolder->ident,$subfolder->owner)); |
|---|
| 112 |
$filepath = $CFG->wwwroot . user_info("username",$folder->files_owner) . "/files/" . $subfolder->ident; |
|---|
| 113 |
$folder_html .= <<< END |
|---|
| 114 |
|
|---|
| 115 |
<div class="photogallery-file-container"> |
|---|
| 116 |
<div class="photogallery-file-image"> |
|---|
| 117 |
<a href="{$filepath}"><img src="{$CFG->wwwroot}_files/folder.png" /></a> |
|---|
| 118 |
</div> |
|---|
| 119 |
<div class="photogallery-file-info"> |
|---|
| 120 |
<h2 class="photogallery-file-title"><a href="{$filepath}">{$subfolder->name}</a></h2> |
|---|
| 121 |
<p class="photogallery-file-keywords"> |
|---|
| 122 |
{$keywords} |
|---|
| 123 |
</p> |
|---|
| 124 |
<p class="photogallery-file-infobar"> |
|---|
| 125 |
{$folderlinks} |
|---|
| 126 |
</p> |
|---|
| 127 |
</div> |
|---|
| 128 |
</div> |
|---|
| 129 |
|
|---|
| 130 |
END; |
|---|
| 131 |
} |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
if (!empty($file_html)) { |
|---|
| 135 |
$file_html = "<h2>" . __gettext("Non-photo files") . "</h2>" . $file_html; |
|---|
| 136 |
} |
|---|
| 137 |
|
|---|
| 138 |
if (!empty($folder_html)) { |
|---|
| 139 |
$folder_html = "<h2>" . __gettext("Subfolders") . "</h2>" . $folder_html; |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
$body = $photo_html . $file_html . $folder_html; |
|---|
| 143 |
if (empty($body)) { |
|---|
| 144 |
$body = "<p>" . __gettext("This folder is currently empty.") . "</p>"; |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
return $body; |
|---|
| 148 |
|
|---|
| 149 |
} |
|---|
| 150 |
|
|---|
| 151 |
function photogallery_folder_preview($folder) { |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
?> |
|---|