Merge branch 'master' of github.com:gallery/gallery3-contrib
This commit is contained in:
commit
6db001616b
258
modules/downloadalbum/controllers/downloadalbum.php
Normal file
258
modules/downloadalbum/controllers/downloadalbum.php
Normal file
|
@ -0,0 +1,258 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class downloadalbum_Controller extends Controller {
|
||||
|
||||
/**
|
||||
* Generate a ZIP on-the-fly.
|
||||
*/
|
||||
public function zip($id) {
|
||||
$album = $this->init($id);
|
||||
$files = $this->getFilesList($album);
|
||||
|
||||
// Calculate ZIP size (look behind for details)
|
||||
$zipsize = 22;
|
||||
foreach($files as $f) {
|
||||
$zipsize += 76 + 2*strlen($f) + filesize($f);
|
||||
}
|
||||
|
||||
// Send headers
|
||||
$this->prepareOutput();
|
||||
$this->sendHeaders($album->name.'.zip', $zipsize);
|
||||
|
||||
// Generate and send ZIP file
|
||||
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT (v6.3.2)
|
||||
$lfh_offset = 0;
|
||||
$cds = '';
|
||||
$cds_offset = 0;
|
||||
foreach($files as $f) {
|
||||
$f_namelen = strlen($f);
|
||||
$f_size = filesize($f);
|
||||
$f_mtime = $this->unix2dostime(filemtime($f));
|
||||
$f_crc32 = hexdec(hash_file('crc32b', $f, false));
|
||||
|
||||
// Local file header
|
||||
echo pack('VvvvVVVVvva' . $f_namelen,
|
||||
0x04034b50, // local file header signature (4 bytes)
|
||||
0x0a, // version needed to extract (2 bytes) => 1.0
|
||||
0x0800, // general purpose bit flag (2 bytes) => UTF-8
|
||||
0x00, // compression method (2 bytes) => store
|
||||
$f_mtime, // last mod file time and date (4 bytes)
|
||||
$f_crc32, // crc-32 (4 bytes)
|
||||
$f_size, // compressed size (4 bytes)
|
||||
$f_size, // uncompressed size (4 bytes)
|
||||
$f_namelen, // file name length (2 bytes)
|
||||
0, // extra field length (2 bytes)
|
||||
|
||||
$f // file name (variable size)
|
||||
// extra field (variable size) => n/a
|
||||
);
|
||||
|
||||
// File data
|
||||
readfile($f);
|
||||
|
||||
// Data descriptor (n/a)
|
||||
|
||||
// Central directory structure: File header
|
||||
$cds .= pack('VvvvvVVVVvvvvvVVa' . $f_namelen,
|
||||
0x02014b50, // central file header signature (4 bytes)
|
||||
0x031e, // version made by (2 bytes) => v3 / Unix
|
||||
0x0a, // version needed to extract (2 bytes) => 1.0
|
||||
0x0800, // general purpose bit flag (2 bytes) => UTF-8
|
||||
0x00, // compression method (2 bytes) => store
|
||||
$f_mtime, // last mod file time and date (4 bytes)
|
||||
$f_crc32, // crc-32 (4 bytes)
|
||||
$f_size, // compressed size (4 bytes)
|
||||
$f_size, // uncompressed size (4 bytes)
|
||||
$f_namelen, // file name length (2 bytes)
|
||||
0, // extra field length (2 bytes)
|
||||
0, // file comment length (2 bytes)
|
||||
0, // disk number start (2 bytes)
|
||||
0, // internal file attributes (2 bytes)
|
||||
0x81b40000, // external file attributes (4 bytes) => chmod 664
|
||||
$lfh_offset, // relative offset of local header (4 bytes)
|
||||
|
||||
$f // file name (variable size)
|
||||
// extra field (variable size) => n/a
|
||||
// file comment (variable size) => n/a
|
||||
);
|
||||
|
||||
// Update local file header/central directory structure offset
|
||||
$cds_offset = $lfh_offset += 30 + $f_namelen + $f_size;
|
||||
}
|
||||
|
||||
// Archive decryption header (n/a)
|
||||
// Archive extra data record (n/a)
|
||||
|
||||
// Central directory structure: Digital signature (n/a)
|
||||
echo $cds; // send Central directory structure
|
||||
|
||||
// Zip64 end of central directory record (n/a)
|
||||
// Zip64 end of central directory locator (n/a)
|
||||
|
||||
// End of central directory record
|
||||
$numfile = count($files);
|
||||
$cds_len = strlen($cds);
|
||||
echo pack('VvvvvVVv',
|
||||
0x06054b50, // end of central dir signature (4 bytes)
|
||||
0, // number of this disk (2 bytes)
|
||||
0, // number of the disk with the start of
|
||||
// the central directory (2 bytes)
|
||||
$numfile, // total number of entries in the
|
||||
// central directory on this disk (2 bytes)
|
||||
$numfile, // total number of entries in the
|
||||
// central directory (2 bytes)
|
||||
$cds_len, // size of the central directory (4 bytes)
|
||||
$cds_offset, // offset of start of central directory
|
||||
// with respect to the
|
||||
// starting disk number (4 bytes)
|
||||
0 // .ZIP file comment length (2 bytes)
|
||||
// .ZIP file comment (variable size)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
private function init($id) {
|
||||
$item = ORM::factory("item", $id);
|
||||
|
||||
// Only send an album
|
||||
if (!$item->is_album()) {
|
||||
// @todo: throw an exception?
|
||||
Kohana::log('error', 'item is not an album: '.$item->relative_path());
|
||||
exit;
|
||||
}
|
||||
|
||||
// Must have view_full to download the originals files
|
||||
access::required("view_full", $item);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the files that must be included in the archive.
|
||||
*/
|
||||
private function getFilesList($album) {
|
||||
$files = array();
|
||||
|
||||
// Go to the parent of album so the ZIP will not contains all the
|
||||
// server hierarchy
|
||||
if (!chdir($album->file_path().'/../')) {
|
||||
// @todo: throw an exception?
|
||||
Kohana::log('error', 'unable to chdir('.$item->file_path().'/../)');
|
||||
exit;
|
||||
}
|
||||
$cwd = getcwd();
|
||||
|
||||
$items = $album->viewable()
|
||||
->descendants(null, null, array(array("type", "<>", "album")));
|
||||
foreach($items as $i) {
|
||||
if (!access::can('view_full', $i)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$relative_path = str_replace($cwd.'/', '', realpath($i->file_path()));
|
||||
if (!is_readable($relative_path)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$files[] = $relative_path;
|
||||
}
|
||||
|
||||
if (count($files) === 0) {
|
||||
// @todo: throw an exception?
|
||||
Kohana::log('error', 'no zippable files in ['.$album->relative_path().']');
|
||||
exit;
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* See system/helpers/download.php
|
||||
*/
|
||||
private function prepareOutput() {
|
||||
// Close output buffers
|
||||
Kohana::close_buffers(FALSE);
|
||||
// Clear any output
|
||||
Event::add('system.display', create_function('', 'Kohana::$output = "";'));
|
||||
}
|
||||
|
||||
/**
|
||||
* See system/helpers/download.php
|
||||
*/
|
||||
private function sendHeaders($filename, $filesize = null) {
|
||||
if (!is_null($filesize)) {
|
||||
header('Content-Length: '.$filesize);
|
||||
}
|
||||
|
||||
// Retrieve MIME type by extension
|
||||
$mime = Kohana::config('mimes.'.strtolower(substr(strrchr($filename, '.'), 1)));
|
||||
$mime = empty($mime) ? 'application/octet-stream' : $mime[0];
|
||||
header("Content-Type: $mime");
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
||||
// Send headers necessary to invoke a "Save As" dialog
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
|
||||
// Prevent caching
|
||||
header('Expires: Thu, 01 Jan 1970 00:00:00 GMT');
|
||||
|
||||
if (request::user_agent('browser') === 'Internet Explorer'
|
||||
AND request::user_agent('version') <= '6.0')
|
||||
{
|
||||
// HTTP 1.0
|
||||
header('Pragma:');
|
||||
|
||||
// HTTP 1.1 with IE extensions
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
}
|
||||
else
|
||||
{
|
||||
// HTTP 1.0
|
||||
header('Pragma: no-cache');
|
||||
|
||||
// HTTP 1.1
|
||||
header('Cache-Control: no-cache, max-age=0');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer DOS date and time
|
||||
* @param integer _timestamp Unix timestamp
|
||||
* @desc returns DOS date and time of the timestamp
|
||||
*/
|
||||
private function unix2dostime($timestamp)
|
||||
{
|
||||
$timebit = getdate($timestamp);
|
||||
|
||||
if ($timebit['year'] < 1980) {
|
||||
return (1 << 21 | 1 << 16);
|
||||
}
|
||||
|
||||
$timebit['year'] -= 1980;
|
||||
|
||||
return ($timebit['year'] << 25 | $timebit['mon'] << 21 |
|
||||
$timebit['mday'] << 16 | $timebit['hours'] << 11 |
|
||||
$timebit['minutes'] << 5 | $timebit['seconds'] >> 1);
|
||||
}
|
||||
}
|
3
modules/downloadalbum/css/downloadalbum_menu.css
Normal file
3
modules/downloadalbum/css/downloadalbum_menu.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
#g-view-menu #g-download-album-link {
|
||||
background-image: url('../images/ico-view-downloadalbum.png');
|
||||
}
|
32
modules/downloadalbum/helpers/downloadalbum_event.php
Normal file
32
modules/downloadalbum/helpers/downloadalbum_event.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class downloadalbum_event_Core {
|
||||
static function album_menu($menu, $theme) {
|
||||
if (access::can("view_full", $theme->item)) {
|
||||
$downloadLink = url::site("downloadalbum/zip/{$theme->item->id}");
|
||||
$menu
|
||||
->append(Menu::factory("link")
|
||||
->id("downloadalbum")
|
||||
->label(t("Download Album"))
|
||||
->url($downloadLink)
|
||||
->css_id("g-download-album-link"));
|
||||
}
|
||||
}
|
||||
}
|
26
modules/downloadalbum/helpers/downloadalbum_theme.php
Normal file
26
modules/downloadalbum/helpers/downloadalbum_theme.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class downloadalbum_theme {
|
||||
static function head($theme) {
|
||||
if ($theme->item && access::can("view_full", $theme->item)) {
|
||||
$theme->css("downloadalbum_menu.css");
|
||||
}
|
||||
}
|
||||
}
|
BIN
modules/downloadalbum/images/ico-view-downloadalbum.png
Normal file
BIN
modules/downloadalbum/images/ico-view-downloadalbum.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
3
modules/downloadalbum/module.info
Normal file
3
modules/downloadalbum/module.info
Normal file
|
@ -0,0 +1,3 @@
|
|||
name = "DownloadAlbum"
|
||||
description = "Displays a link to download a ZIP archive of the current album."
|
||||
version = 1
|
|
@ -47,16 +47,24 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
|||
|
||||
foreach (module::available() as $this_module_name => $module_info) {
|
||||
|
||||
$remote_version = '';
|
||||
$remote_server = '';
|
||||
|
||||
list ($remote_version, $remote_server) = $this->get_remote_module_version($this_module_name);
|
||||
|
||||
$font_color = "black";
|
||||
if ($remote_version == "DNE") {
|
||||
$font_color = "blue";
|
||||
} else if ($remote_version < $module_info->code_version) {
|
||||
} else if ($module_info->version != '' and $module_info->code_version < $module_info->version) {
|
||||
$font_color = "pink";
|
||||
} else if ($module_info->version != '' and $module_info->code_version > $module_info->version) {
|
||||
$font_color = "orange";
|
||||
} else if ($remote_version < $module_info->code_version or ($module_info->version != '' and $remote_version < $module_info->version)) {
|
||||
$font_color = "green";
|
||||
} else if ($remote_version > $module_info->code_version) {
|
||||
} else if ($remote_version > $module_info->code_version or ($module_info->version != '' and $remote_version > $module_info->version)) {
|
||||
$font_color = "red";
|
||||
}
|
||||
|
||||
$all_modules->$this_module_name = array ("name" => $module_info->name, "locked" => $module_info->locked,
|
||||
"code_version" => $module_info->code_version, "active" => $module_info->active,
|
||||
"version" => $module_info->version,"description" => $module_info->description,
|
||||
|
@ -91,7 +99,9 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
|||
|
||||
try {
|
||||
$file = fopen ("http://github.com/gallery/gallery3/raw/master/modules/".$module_name."/module.info", "r");
|
||||
$server = '(G3)';
|
||||
if ($file != null) {
|
||||
$server = '(G3)';
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
//echo 'Message: ' .$e->getMessage() . '<br>';
|
||||
|
@ -100,7 +110,9 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
|||
if ($file == null) {
|
||||
try {
|
||||
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/modules/".$module_name."/module.info", "r");
|
||||
$server = '(G3CC)';
|
||||
if ($file != null) {
|
||||
$server = '(G3CC)';
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
//echo 'Message: ' .$e->getMessage() . '<br>';
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
|
||||
<div id="g-admin-moduleupdates" class="g-block">
|
||||
<h1> <?= t("Module Updates") ?> </h1>
|
||||
<h1> <?= t("Module Updates v1.2") ?> </h1>
|
||||
<p>
|
||||
<?= t("Compares your installed module version against the ones stored in the GitHub.<br><br>") ?>
|
||||
<?= t("<font color=red>Red = Out of Date</font><br>") ?>
|
||||
<?= t("<font color=green>Green = Your version is newer</font><br>") ?>
|
||||
<?= t("<font color=red>Red = Your version is older than the GitHub</font><br>") ?>
|
||||
<?= t("<font color=green>Green = Your version is newer than the GitHub</font><br>") ?>
|
||||
<?= t("<font color=orange>Orange = Your file version is newer than the installed version</font><br>") ?>
|
||||
<?= t("<font color=pink>Pink = Your installed version is newer than file version</font><br>") ?>
|
||||
<?= t("<font color=blue>Blue = Does Not Exist/No information available</font><br>") ?>
|
||||
</p>
|
||||
|
||||
|
@ -17,14 +19,14 @@
|
|||
<table>
|
||||
<tr>
|
||||
<th> <?= t("Module") ?> </th>
|
||||
<th> <?= t("Your Version") ?> </th>
|
||||
<th> <?= t("Your Version<br>[File/Installed]") ?> </th>
|
||||
<th> <?= t("Remote Version") ?> </th>
|
||||
<th> <?= t("Description") ?> </th>
|
||||
</tr>
|
||||
<? foreach ($vars as $module_name): ?>
|
||||
<tr class="<?= text::alternate("g-odd", "g-even") ?>">
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['name'] ?> </font> </td>
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['code_version'] ?> </font> </td>
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['code_version'] ?><? if ($module_name['version'] != '') echo "/".$module_name['version']; ?> </font> </td>
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['remote_version'] ?> <?= $module_name['remote_server'] ?> </font> </td>
|
||||
<td> <? echo "<font color=".$module_name['font_color'].">"; ?> <?= $module_name['description'] ?> </font> </td>
|
||||
</tr>
|
||||
|
|
|
@ -178,13 +178,13 @@ class user_homes_event_Core {
|
|||
}
|
||||
}
|
||||
|
||||
static function album_add_form($form){
|
||||
static function album_add_form($parent, $form){
|
||||
|
||||
$group = $form->group("privacy")
|
||||
->label(t("album privacy settings"));
|
||||
$group->checkbox("private")->label(t("Private"))->id("uh_private")->onClick("pc()");
|
||||
$group->input("username")->label(t("Username"))->id("uh_username")
|
||||
->callback("user_homes_event::user_already_exists")
|
||||
->callback("user_homes_event::valid_name")
|
||||
->error_messages("in_use", t("There is already a user with that username"))
|
||||
->error_messages("required", t("You must enter a username"))->callback("user_homes_event::valid_name")->rules("length[1,32]");
|
||||
$group->password("password")->label(t("Password"))->id("uh_password")
|
||||
|
|
|
@ -43,6 +43,9 @@ $(document).ready(function() {
|
|||
});
|
||||
}
|
||||
|
||||
// Remove titles for menu options since we're displaying that text anyway
|
||||
$(".sf-menu a, .sf-menu li").removeAttr("title");
|
||||
|
||||
// Album and search results views
|
||||
/*if ($("#g-album-grid").length) {
|
||||
// Set equal height for album items and vertically align thumbnails/metadata
|
||||
|
|
|
@ -4,5 +4,5 @@ version = 1
|
|||
author = "Romain LE DISEZ"
|
||||
site = 1
|
||||
admin = 0
|
||||
;wind commit = 2bbce8dddb0ab0a00aee727e2f639b793988a1d1
|
||||
;wind date = Thu Jun 17 09:10:01 2010 -0700
|
||||
;wind commit = 3b05db2685d92ca538d7993c960b06ea32f3a8df
|
||||
;wind date = Wed Jun 23 11:16:56 2010 -0700
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<? endforeach ?>
|
||||
<? else: ?>
|
||||
<? if ($user->admin || access::can("add", $item)): ?>
|
||||
<? $addurl = url::file("index.php/simple_uploader/app/$item->id") ?>
|
||||
<? $addurl = url::site("flash_uploader/app/$item->id") ?>
|
||||
<li><?= t("There aren't any photos here yet! <a %attrs>Add some</a>.",
|
||||
array("attrs" => html::mark_clean("href=\"$addurl\" class=\"g-dialog-link\""))) ?></li>
|
||||
<? else: ?>
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
uploader: "<?= url::file("lib/uploadify/uploadify.swf") ?>",
|
||||
script: "<?= url::site("simple_uploader/add_photo/{$album->id}") ?>",
|
||||
scriptData: <?= json_encode($script_data) ?>,
|
||||
fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4",
|
||||
fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.m4v;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4;*.M4V",
|
||||
fileDesc: <?= t("Photos and movies")->for_js() ?>,
|
||||
cancelImg: "<?= url::file("lib/uploadify/cancel.png") ?>",
|
||||
simUploadLimit: <?= $simultaneous_upload_limit ?>,
|
||||
|
@ -166,4 +166,4 @@
|
|||
</ul>
|
||||
</div>
|
||||
*/
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -95,11 +95,13 @@
|
|||
the immediate parent so that when you go back up a
|
||||
level you're on the right page. -->
|
||||
<a href="<?= $parent->url($parent == $theme->item()->parent() ?
|
||||
"show={$theme->item()->id}" : null) ?>"><?= html::purify($parent->title) ?></a>
|
||||
"show={$theme->item()->id}" : null) ?>"><?= text::limit_chars(html::purify($parent->title), 15) ?></a>
|
||||
</li>
|
||||
<? $i++ ?>
|
||||
<? endforeach ?>
|
||||
<li class="g-active<? if ($i == 0) print " g-first" ?>"><?= html::purify($theme->item()->title) ?></li>
|
||||
<li class="g-active<? if ($i == 0) print " g-first" ?>">
|
||||
<?= text::limit_chars(html::purify($theme->item()->title), 15) ?>
|
||||
</li>
|
||||
</ul>
|
||||
<? endif ?>
|
||||
</div>
|
||||
|
|
Reference in New Issue
Block a user