1
0

Merge pull request #106 from rWatcher/master

Updates to CalendarView, EditCreation, NoFFMPEG, Qutoas, and rWInfo
This commit is contained in:
Tim Almdal 2012-04-16 22:15:52 -07:00
commit e8a14800a0
11 changed files with 131 additions and 497 deletions

View File

@ -31,18 +31,19 @@ class CalendarView_Controller extends Controller {
}
// Draw the page.
$template = new Theme_View("calpage.html", "other", "CalendarView");
$template->set_global("calendar_user", $display_user);
$root = item::root();
$template = new Theme_View("page.html", "other", "CalendarView");
$template->set_global(
array("calendar_user" => $display_user,
"breadcrumbs" => array(
Breadcrumb::instance($root->title, $root->url())->set_first(),
Breadcrumb::instance($display_year, url::site("calendarview/calendar/" . $display_year))->set_last())));
$template->page_title = t("Gallery :: Calendar");
$template->content = new View("calendarview_year.html");
$template->content->calendar_year = $display_year;
$template->content->calendar_user = $display_user;
$template->content->calendar_user_year_form = $this->_get_calenderprefs_form($display_year, $display_user);
$template->content->title = t("Calendar") . ": " . $display_year;
// Set up breadcrumbs
$calendar_breadcrumbs[0] = new Calendar_Breadcrumb(item::root()->title, item::root()->url());
$calendar_breadcrumbs[1] = new Calendar_Breadcrumb($display_year, "");
$template->set_global("breadcrumbs", $calendar_breadcrumbs);
print $template;
}
@ -81,42 +82,42 @@ class CalendarView_Controller extends Controller {
throw new Kohana_404_Exception();
}
// Set up the page.
$template = new Theme_View("calpage.html", "collection", "CalendarDayView");
$template->set_global("page", $page);
$template->set_global("max_pages", $max_pages);
$template->set_global("page_size", $page_size);
$template->page_title = t("Gallery :: Calendar");
// Figure out which photos go on this page.
$children = "";
if ($display_user == "-1") {
$template->set_global("children", ORM::factory("item")
$children = ORM::factory("item")
->viewable()
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
->order_by("captured", "ASC")
->find_all($page_size, $offset));
->find_all($page_size, $offset);
} else {
$template->set_global("children", ORM::factory("item")
$children = ORM::factory("item")
->viewable()
->where("owner_id", "=", $display_user)
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, $display_day, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month, ($display_day + 1), $display_year))
->order_by("captured", "ASC")
->find_all($page_size, $offset));
->find_all($page_size, $offset);
}
// Set up breadcrumbs
$calendar_breadcrumbs[0] = new Calendar_Breadcrumb(item::root()->title, item::root()->url());
$calendar_breadcrumbs[1] = new Calendar_Breadcrumb($display_year, url::site("calendarview/calendar/" . $display_year . "/" . $display_user));
$calendar_breadcrumbs[2] = new Calendar_Breadcrumb(t(date("F", mktime(0, 0, 0, $display_month, $display_day, $display_year))), url::site("calendarview/month/" . $display_year . "/" . $display_user . "/" . $display_month));
$calendar_breadcrumbs[3] = new Calendar_Breadcrumb($display_day, "");
$template->set_global("breadcrumbs", $calendar_breadcrumbs);
// Finish setting up and then display the page.
$template->set_global("children_count", $day_count);
// Create and display the page.
$root = item::root();
$template = new Theme_View("page.html", "collection", "CalendarDayView");
$template->set_global(
array("page" => $page,
"max_pages" => $max_pages,
"page_size" => $page_size,
"children" => $children,
"breadcrumbs" => array(
Breadcrumb::instance($root->title, $root->url())->set_first(),
Breadcrumb::instance($display_year, url::site("calendarview/calendar/" . $display_year . "/" . $display_user)),
Breadcrumb::instance(t(date("F", mktime(0, 0, 0, $display_month, $display_day, $display_year))), url::site("calendarview/month/" . $display_year . "/" . $display_user . "/" . $display_month)),
Breadcrumb::instance($display_day, url::site("calendarview/month/" . $display_year . "/" . $display_user . "/" . $display_month . "/" . $display_day))->set_last()),
"children_count" => $day_count));
$template->page_title = t("Gallery :: Calendar");
$template->content = new View("dynamic.html");
$template->content->title = t("Photos From ") . date("d", mktime(0, 0, 0, $display_month, $display_day, $display_year)) . " " . t(date("F", mktime(0, 0, 0, $display_month, $display_day, $display_year))) . " " . date("Y", mktime(0, 0, 0, $display_month, $display_day, $display_year));
print $template;
@ -157,41 +158,41 @@ class CalendarView_Controller extends Controller {
throw new Kohana_404_Exception();
}
// Set up the page.
$template = new Theme_View("calpage.html", "collection", "CalendarMonthView");
$template->set_global("page", $page);
$template->set_global("max_pages", $max_pages);
$template->set_global("page_size", $page_size);
$template->page_title = t("Gallery :: Calendar");
// Figure out which photos go on this page.
$children = "";
if ($display_user == "-1") {
$template->set_global("children", ORM::factory("item")
$children = ORM::factory("item")
->viewable()
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, 1, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month+1, 1, $display_year))
->order_by("captured", "ASC")
->find_all($page_size, $offset));
->find_all($page_size, $offset);
} else {
$template->set_global("children", ORM::factory("item")
$children = ORM::factory("item")
->viewable()
->where("owner_id", "=", $display_user)
->where("type", "!=", "album")
->where("captured", ">=", mktime(0, 0, 0, $display_month, 1, $display_year))
->where("captured", "<", mktime(0, 0, 0, $display_month+1, 1, $display_year))
->order_by("captured", "ASC")
->find_all($page_size, $offset));
->find_all($page_size, $offset);
}
// Set up breadcrumbs
$calendar_breadcrumbs[0] = new Calendar_Breadcrumb(item::root()->title, item::root()->url());
$calendar_breadcrumbs[1] = new Calendar_Breadcrumb($display_year, url::site("calendarview/calendar/" . $display_year . "/" . $display_user));
$calendar_breadcrumbs[2] = new Calendar_Breadcrumb(t(date("F", mktime(0, 0, 0, $display_month, 1, $display_year))), "");
$template->set_global("breadcrumbs", $calendar_breadcrumbs);
// Finish setting up and then display the page.
$template->set_global("children_count", $day_count);
// Create and display the page.
$root = item::root();
$template = new Theme_View("page.html", "collection", "CalendarMonthView");
$template->set_global(
array("page" => $page,
"max_pages" => $max_pages,
"page_size" => $page_size,
"breadcrumbs" => array(
Breadcrumb::instance($root->title, $root->url())->set_first(),
Breadcrumb::instance($display_year, url::site("calendarview/calendar/" . $display_year . "/" . $display_user)),
Breadcrumb::instance(t(date("F", mktime(0, 0, 0, $display_month, 1, $display_year))), url::site("calendarview/month/" . $display_year . "/" . $display_user . "/" . $display_month))->set_last()),
"children" => $children,
"children_count" => $day_count));
$template->page_title = t("Gallery :: Calendar");
$template->content = new View("dynamic.html");
$template->content->title = t("Photos From ") . t(date("F", mktime(0, 0, 0, $display_month, 1, $display_year))) . " " . date("Y", mktime(0, 0, 0, $display_month, 1, $display_year));
print $template;
@ -266,4 +267,4 @@ class CalendarView_Controller extends Controller {
// redirect to the currect page.
url::redirect(url::site("calendarview/calendar/" . $str_year_id . "/" . $str_user_id, request::protocol()));
}
}
}

View File

@ -1,31 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2012 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 Calendar_Breadcrumb_Core {
// Creates a class to maintain a single breadcrumb.
// Multiple breadcrumbs can be achieved by createing an array of this class type.
public $title = "";
public $id = 1;
public $url = "";
public function __construct($new_title, $new_url) {
$this->title = $new_title;
$this->url = $new_url;
}
}

View File

@ -1,164 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?= $theme->html_attributes() ?> xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<? $theme->start_combining("script,css") ?>
<title>
<? if ($page_title): ?>
<?= $page_title ?>
<? else: ?>
<? if ($theme->item()): ?>
<?= $theme->item()->title ?>
<? elseif ($theme->tag()): ?>
<?= t("Photos tagged with %tag_title", array("tag_title" => $theme->tag()->name)) ?>
<? else: /* Not an item, not a tag, no page_title specified. Help! */ ?>
<?= item::root()->title ?>
<? endif ?>
<? endif ?>
</title>
<link rel="shortcut icon"
href="<?= url::file(module::get_var("gallery", "favicon_url")) ?>"
type="image/x-icon" />
<? if ($theme->page_type == "collection"): ?>
<? if ($thumb_proportion != 1): ?>
<? $new_width = round($thumb_proportion * 213) ?>
<? $new_height = round($thumb_proportion * 240) ?>
<style type="text/css">
.g-view #g-content #g-album-grid .g-item {
width: <?= $new_width ?>px;
height: <?= $new_height ?>px;
/* <?= $thumb_proportion ?> */
}
</style>
<? endif ?>
<? endif ?>
<?= $theme->script("json2-min.js") ?>
<?= $theme->script("jquery.js") ?>
<?= $theme->script("jquery.form.js") ?>
<?= $theme->script("jquery-ui.js") ?>
<?= $theme->script("gallery.common.js") ?>
<? /* MSG_CANCEL is required by gallery.dialog.js */ ?>
<script type="text/javascript">
var MSG_CANCEL = <?= t('Cancel')->for_js() ?>;
</script>
<?= $theme->script("gallery.ajax.js") ?>
<?= $theme->script("gallery.dialog.js") ?>
<?= $theme->script("superfish/js/superfish.js") ?>
<?= $theme->script("jquery.localscroll.js") ?>
<? /* These are page specific but they get combined */ ?>
<? if ($theme->page_subtype == "photo"): ?>
<?= $theme->script("jquery.scrollTo.js") ?>
<?= $theme->script("gallery.show_full_size.js") ?>
<? elseif ($theme->page_subtype == "movie"): ?>
<?= $theme->script("flowplayer.js") ?>
<? endif ?>
<?= $theme->head() ?>
<? /* Theme specific CSS/JS goes last so that it can override module CSS/JS */ ?>
<?= $theme->script("ui.init.js") ?>
<?= $theme->css("yui/reset-fonts-grids.css") ?>
<?= $theme->css("superfish/css/superfish.css") ?>
<?= $theme->css("themeroller/ui.base.css") ?>
<?= $theme->css("screen.css") ?>
<!--[if lte IE 8]>
<link rel="stylesheet" type="text/css" href="<?= $theme->url("css/fix-ie.css") ?>"
media="screen,print,projection" />
<![endif]-->
<!-- LOOKING FOR YOUR JAVASCRIPT? It's all been combined into the link below -->
<?= $theme->get_combined("script") ?>
<!-- LOOKING FOR YOUR CSS? It's all been combined into the link below -->
<?= $theme->get_combined("css") ?>
</head>
<body <?= $theme->body_attributes() ?>>
<?= $theme->page_top() ?>
<div id="doc4" class="yui-t5 g-view">
<?= $theme->site_status() ?>
<div id="g-header" class="ui-helper-clearfix">
<div id="g-banner">
<? if ($header_text = module::get_var("gallery", "header_text")): ?>
<?= $header_text ?>
<? else: ?>
<a id="g-logo" class="g-left" href="<?= item::root()->url() ?>" title="<?= t("go back to the Gallery home")->for_html_attr() ?>">
<img width="107" height="48" alt="<?= t("Gallery logo: Your photos on your web site")->for_html_attr() ?>" src="<?= url::file("lib/images/logo.png") ?>" />
</a>
<? endif ?>
<?= $theme->user_menu() ?>
<?= $theme->header_top() ?>
<!-- hide the menu until after the page has loaded, to minimize menu flicker -->
<div id="g-site-menu" style="visibility: hidden">
<?= $theme->site_menu($theme->item() ? "#g-item-id-{$theme->item()->id}" : "") ?>
</div>
<script type="text/javascript"> $(document).ready(function() { $("#g-site-menu").css("visibility", "visible"); }) </script>
<?= $theme->header_bottom() ?>
</div>
<? // The following code was modifed to allow module-defined breadcrumbs.
// Everything else in this file is a copy of the default page.html.php file.
?>
<? if (!empty($breadcrumbs)): ?>
<ul class="g-breadcrumbs">
<? $i = 0 ?>
<? foreach ($breadcrumbs as $breadcrumb): ?>
<li<? if ($i == 0) print " class=\"g-first\"" ?>>
<!-- Adding ?show=<id> causes Gallery3 to display the page
containing that photo. For now, we just do it for
the immediate parent so that when you go back up a
level you're on the right page. -->
<? if ($breadcrumb->url) : ?>
<a href="<?= $breadcrumb->url ?>"><?= html::purify($breadcrumb->title) ?></a>
<? else : ?>
<?= html::purify($breadcrumb->title) ?>
<? endif ?>
</li>
<? $i++ ?>
<? endforeach ?>
</ul>
<? endif ?>
<? // End modified code ?>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<div id="g-content" class="yui-g">
<?= $theme->messages() ?>
<?= $content ?>
</div>
</div>
</div>
<div id="g-sidebar" class="yui-b">
<? if ($theme->page_subtype != "login"): ?>
<?= new View("sidebar.html") ?>
<? endif ?>
</div>
</div>
<div id="g-footer" class="ui-helper-clearfix">
<?= $theme->footer() ?>
<? if ($footer_text = module::get_var("gallery", "footer_text")): ?>
<?= $footer_text ?>
<? endif ?>
<? if (module::get_var("gallery", "show_credits")): ?>
<ul id="g-credits" class="g-inline">
<?= $theme->credits() ?>
</ul>
<? endif ?>
</div>
</div>
<?= $theme->page_bottom() ?>
</body>
</html>

View File

@ -1,6 +1,9 @@
form#g-edit-album-form fieldset ul li input,
form#g-edit-album-form fieldset ul li select,
form#g-edit-album-form fieldset ul li textarea,
form#g-edit-movie-form fieldset ul li input,
form#g-edit-movie-form fieldset ul li select,
form#g-edit-movie-form fieldset ul li textarea,
form#g-edit-photo-form fieldset ul li input,
form#g-edit-photo-form fieldset ul li select,
form#g-edit-photo-form fieldset ul li textarea {

View File

@ -23,10 +23,6 @@
*
* Note: by design, this class does not do any permission checking.
*/
// rWatcher edit: include MP4Info.php library.
include MODPATH . "noffmpeg/libraries/MP4Info.php";
class movie_Core {
static function get_edit_form($movie) {
$form = new Forge("movies/update/$movie->id", "", "post", array("id" => "g-edit-movie-form"));
@ -62,86 +58,38 @@ class movie_Core {
}
static function extract_frame($input_file, $output_file) {
$ffmpeg = movie::find_ffmpeg();
if (empty($ffmpeg)) {
// BEGIN rWatcher Edit.
copy(MODPATH . "noffmpeg/images/missing_movie.png", $output_file);
//throw new Exception("@todo MISSING_FFMPEG");
// END rWatcher Edit.
}
$cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($input_file) .
" -an -ss 00:00:03 -an -r 1 -vframes 1" .
" -y -f mjpeg " . escapeshellarg($output_file) . " 2>&1";
exec($cmd);
clearstatcache(); // use $filename parameter when PHP_version is 5.3+
if (filesize($output_file) == 0) {
// Maybe the movie is shorter, fall back to the first frame.
$cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($input_file) .
" -an -an -r 1 -vframes 1" .
" -y -f mjpeg " . escapeshellarg($output_file) . " 2>&1";
exec($cmd);
clearstatcache();
if (filesize($output_file) == 0) {
throw new Exception("@todo FFMPEG_FAILED");
}
}
// rWatcher Edit: Just copy the generic thumb instead of extracting a frame.
copy(MODPATH . "noffmpeg/images/missing_movie.png", $output_file);
}
/**
* Return the path to the ffmpeg binary if one exists and is executable, or null.
*/
static function find_ffmpeg() {
if (!($ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) || !file_exists($ffmpeg_path)) {
$ffmpeg_path = system::find_binary(
"ffmpeg", module::get_var("gallery", "graphics_toolkit_path"));
module::set_var("gallery", "ffmpeg_path", $ffmpeg_path);
}
return $ffmpeg_path;
// rWatcher Edit: Return true to trick the system into thinking ffmpeg is present.
return true;
}
/**
* Return the width, height, mime_type and extension of the given movie file.
*/
static function get_file_metadata($file_path) {
$ffmpeg = movie::find_ffmpeg();
if (empty($ffmpeg)) {
// BEGIN rWatcher Edit.
$pi = pathinfo($file_path);
$extension = isset($pi["extension"]) ? $pi["extension"] : "flv"; // No extension? Assume FLV.
$mime_type = in_array(strtolower($extension), array("mp4", "m4v")) ?
"video/mp4" : "video/x-flv";
$vid_width = 320;
$vid_height = 240;
if (strtolower($extension) == "flv") {
$flvinfo = new FLVMetaData($file_path);
$info = $flvinfo->getMetaData();
if (($info["width"] != "") && ($info["height"] != "")) {
$vid_width = $info["width"];
$vid_height = $info["height"];
}
}
return array($vid_width, $vid_height, $mime_type, $extension);
//throw new Exception("@todo MISSING_FFMPEG");
// END rWatcher Edit.
}
$cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($file_path) . " 2>&1";
$result = `$cmd`;
if (preg_match("/Stream.*?Video:.*?(\d+)x(\d+)/", $result, $regs)) {
list ($width, $height) = array($regs[1], $regs[2]);
} else {
list ($width, $height) = array(0, 0);
}
// rWatcher Edit: Use FLVMetaData lib instead of ffmpeg for .flv files.
// For other files, just set a 320x240 default video resolution.
$pi = pathinfo($file_path);
$extension = isset($pi["extension"]) ? $pi["extension"] : "flv"; // No extension? Assume FLV.
$mime_type = in_array(strtolower($extension), array("mp4", "m4v")) ?
"video/mp4" : "video/x-flv";
return array($width, $height, $mime_type, $extension);
$vid_width = 320;
$vid_height = 240;
if (strtolower($extension) == "flv") {
$flvinfo = new FLVMetaData($file_path);
$info = $flvinfo->getMetaData();
if (($info["width"] != "") && ($info["height"] != "")) {
$vid_width = $info["width"];
$vid_height = $info["height"];
}
}
return array($vid_width, $vid_height, $mime_type, $extension);
}
}
}

View File

@ -4,4 +4,4 @@ version = 1
author_name = ""
author_url = ""
info_url = "http://codex.gallery2.org/Gallery3:Modules:noffmpeg"
discuss_url = "http://gallery.menalto.com/forum_module_noffmpeg"
discuss_url = "http://gallery.menalto.com/node/97978"

View File

@ -1,164 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript" src="<?= url::file("lib/swfobject.js") ?>"></script>
<script type="text/javascript" src="<?= url::file("lib/uploadify/jquery.uploadify.min.js") ?>"></script>
<script type="text/javascript">
<? $flash_minimum_version = "9.0.24" ?>
<? $movies_allowed = true; // rWatcher EDIT ?>
var success_count = 0;
var error_count = 0;
var updating = 0;
$("#g-add-photos-canvas").ready(function () {
var update_status = function() {
if (updating) {
// poor man's mutex
setTimeout(function() { update_status(); }, 500);
}
updating = 1;
$.get("<?= url::site("uploader/status/_S/_E") ?>"
.replace("_S", success_count).replace("_E", error_count),
function(data) {
$("#g-add-photos-status-message").html(data);
updating = 0;
});
};
if (swfobject.hasFlashPlayerVersion("<?= $flash_minimum_version ?>")) {
$("#g-uploadify").uploadify({
width: 150,
height: 33,
uploader: "<?= url::file("lib/uploadify/uploadify.swf") ?>",
script: "<?= url::site("uploader/add_photo/{$album->id}") ?>",
scriptData: <?= json_encode($script_data) ?>,
fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.GIF;*.JPG;*.JPEG;*.PNG<? if ($movies_allowed): ?>;*.flv;*.mp4;*.m4v;*.FLV;*.MP4;*.M4V<? endif ?>",
fileDesc: <?= t("Photos and movies")->for_js() ?>,
cancelImg: "<?= url::file("lib/uploadify/cancel.png") ?>",
simUploadLimit: <?= $simultaneous_upload_limit ?>,
wmode: "transparent",
hideButton: true, /* should be true */
auto: true,
multi: true,
onAllComplete: function(filesUploaded, errors, allbytesLoaded, speed) {
$("#g-upload-cancel-all")
.addClass("ui-state-disabled")
.attr("disabled", "disabled");
$("#g-upload-done")
.removeClass("ui-state-disabled")
.attr("disabled", null);
return true;
},
onClearQueue: function(event) {
$("#g-upload-cancel-all")
.addClass("ui-state-disabled")
.attr("disabled", "disabled");
$("#g-upload-done")
.removeClass("ui-state-disabled")
.attr("disabled", null);
return true;
},
onComplete: function(event, queueID, fileObj, response, data) {
var re = /^error: (.*)$/i;
var msg = re.exec(response);
$("#g-add-photos-status ul").append(
"<li id=\"q" + queueID + "\" class=\"g-success\">" + fileObj.name + " - " +
<?= t("Completed")->for_js() ?> + "</li>");
setTimeout(function() { $("#q" + queueID).slideUp("slow").remove() }, 5000);
success_count++;
update_status();
return true;
},
onError: function(event, queueID, fileObj, errorObj) {
var msg = " - ";
if (errorObj.type == "HTTP") {
if (errorObj.info == "500") {
msg += <?= t("Unable to process this file")->for_js() ?>;
// Server error - check server logs
} else if (errorObj.info == "404") {
msg += <?= t("The upload script was not found.")->for_js() ?>;
// Server script not found
} else {
// Server Error: status: errorObj.info
msg += (<?= t("Server error: __INFO__")->for_js() ?>.replace("__INFO__", errorObj.info));
}
} else if (errorObj.type == "File Size") {
var sizelimit = $("#g-uploadify").uploadifySettings(sizeLimit);
msg += fileObj.name+' '+errorObj.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB';
} else {
msg += (<?= t("Server error: __INFO__ (__TYPE__)")->for_js() ?>
.replace("__INFO__", errorObj.info)
.replace("__TYPE__", errorObj.type));
}
$("#g-add-photos-status ul").append(
"<li id=\"q" + queueID + "\" class=\"g-error\">" + fileObj.name + msg + "</li>");
$("#g-uploadify").uploadifyCancel(queueID);
error_count++;
update_status();
},
onSelect: function(event) {
if ($("#g-upload-cancel-all").hasClass("ui-state-disabled")) {
$("#g-upload-cancel-all")
.removeClass("ui-state-disabled")
.attr("disabled", null);
$("#g-upload-done")
.addClass("ui-state-disabled")
.attr("disabled", "disabled");
}
return true;
}
});
} else {
$(".requires-flash").hide();
$(".no-flash").show();
}
});
</script>
<div class="requires-flash">
<? if ($suhosin_session_encrypt || (identity::active_user()->admin && !$movies_allowed)): ?>
<div class="g-message-block g-info">
<? if ($suhosin_session_encrypt): ?>
<p class="g-error">
<?= t("Error: your server is configured to use the <a href=\"%encrypt_url\"><code>suhosin.session.encrypt</code></a> setting from <a href=\"%suhosin_url\">Suhosin</a>. You must disable this setting to upload photos.",
array("encrypt_url" => "http://www.hardened-php.net/suhosin/configuration.html#suhosin.session.encrypt",
"suhosin_url" => "http://www.hardened-php.net/suhosin/")) ?>
</p>
<? endif ?>
<? if (identity::active_user()->admin && !$movies_allowed): ?>
<p class="g-warning">
<?= t("Can't find <i>ffmpeg</i> on your system. Movie uploading disabled. <a href=\"%help_url\">Help!</a>", array("help_url" => "http://codex.gallery2.org/Gallery3:FAQ#Why_does_it_say_I.27m_missing_ffmpeg.3F")) ?>
</p>
<? endif ?>
</div>
<? endif ?>
<div>
<p>
<?= t("Photos will be uploaded to album: ") ?>
</p>
<ul class="g-breadcrumbs ui-helper-clearfix">
<? foreach ($album->parents() as $i => $parent): ?>
<li<? if ($i == 0) print " class=\"g-first\"" ?>> <?= html::clean($parent->title) ?> </li>
<? endforeach ?>
<li class="g-active"> <?= html::purify($album->title) ?> </li>
</ul>
</div>
<div id="g-add-photos-canvas">
<button id="g-add-photos-button" class="g-button ui-state-default ui-corner-all" href="#"><?= t("Select photos...") ?></button>
<span id="g-uploadify"></span>
</div>
<div id="g-add-photos-status">
<ul id="g-action-status" class="g-message-block">
</ul>
</div>
</div>
<div class="no-flash" style="display: none">
<p>
<?= t("Your browser must have Adobe Flash Player version %flash_minimum_version or greater installed to use this feature.", array("flash_minimum_version" => $flash_minimum_version)) ?>
</p>
<a href="http://www.adobe.com/go/getflashplayer">
<img src="<?= request::protocol() ?>://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
alt=<?= t("Get Adobe Flash Player")->for_js() ?> />
</a>
</div>

View File

@ -23,11 +23,11 @@ class quotas_theme_Core {
if (!identity::active_user()->guest) {
$record = ORM::factory("users_space_usage")->where("owner_id", "=", identity::active_user()->id)->find();
if ($record->get_usage_limit() == 0) {
print t("You are using %usage MB", array("usage" => number_format($record->total_usage_mb(), 2)));
print t("You are using %usage", array("usage" => $record->total_usage_string()));
} else {
print t("You are using %usage of your %limit MB limit (%percentage%)",
array("usage" => number_format($record->current_usage_mb(), 2),
"limit" => number_format($record->get_usage_limit_mb(), 2),
print t("You are using %usage of your %limit limit (%percentage%)",
array("usage" => $record->current_usage_string(),
"limit" => $record->get_usage_limit_string(),
"percentage" => number_format((($record->current_usage() / $record->get_usage_limit()) * 100), 2)));
}
}

View File

@ -18,10 +18,22 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Users_Space_Usage_Model_Core extends ORM {
public function partial_usage_mb($file_type) {
// Return a value (in megabytes) for the user's total usage in fullsizes, resizes, or thumbs.
static function _format_usage($bytes) {
$usage_unit = array("B","kB","MB","GB","TB","PB","EB","ZB","YB");
$unit_counter = 0;
while ($bytes >= 1024) {
$bytes = $bytes / 1024;
$unit_counter++;
}
return (number_format($bytes, 2) . " " . $usage_unit[$unit_counter]);
}
public function partial_usage_string($file_type) {
// Return a string for the user's total usage in fullsizes, resizes, or thumbs
// with the appropriate file size prefix.
// $file_type should be either fullsize, resize, or thumb.
return ($this->$file_type / 1024 / 1024);
return (Users_Space_Usage_Model_Core::_format_usage($this->$file_type));
}
public function total_usage() {
@ -29,9 +41,9 @@ class Users_Space_Usage_Model_Core extends ORM {
return ($this->fullsize + $this->resize + $this->thumb);
}
public function total_usage_mb() {
// Return the user's total usage in megabytes.
return (($this->total_usage()) / 1024 / 1024);
public function total_usage_string() {
// Return the user's total usage as a string with the appropriate file size prefix.
return (Users_Space_Usage_Model_Core::_format_usage($this->total_usage()));
}
public function current_usage() {
@ -43,9 +55,10 @@ class Users_Space_Usage_Model_Core extends ORM {
}
}
public function current_usage_mb() {
// Return the users relevant usage in megabytes based on the use_all_sizes setting.
return ($this->current_usage() / 1024 / 1024);
public function current_usage_string() {
// Return the users relevant usage as a string with the appropriate file size prefix
// based on the use_all_sizes setting.
return (Users_Space_Usage_Model_Core::_format_usage($this->current_usage()));
}
public function get_usage_limit() {
@ -68,9 +81,15 @@ class Users_Space_Usage_Model_Core extends ORM {
return 0;
}
public function get_usage_limit_mb() {
// Returns a user's maximum limit in megabytes.
return ($this->get_usage_limit() / 1024 / 1024);
public function get_usage_limit_string() {
// Returns a user's maximum limit as a string with the appropriate file size prefix
// or an infinity symbol if the user has no limit.
$user_limit = $this->get_usage_limit();
if ($user_limit == 0) {
return "&infin;";
} else {
return (Users_Space_Usage_Model_Core::_format_usage($this->get_usage_limit()));
}
}
public function add_item($item) {

View File

@ -34,19 +34,19 @@
<?= html::clean($user->full_name) ?>
</td>
<td>
<?= number_format($record->partial_usage_mb("fullsize"), 2); ?> MB
<?=$record->partial_usage_string("fullsize"); ?>
</td>
<td>
<?= number_format($record->partial_usage_mb("resize"), 2); ?> MB
<?=$record->partial_usage_string("resize"); ?>
</td>
<td>
<?= number_format($record->partial_usage_mb("thumb"), 2); ?> MB
<?=$record->partial_usage_string("thumb"); ?>
</td>
<td>
<?= number_format($record->total_usage_mb(), 2) ?> MB
<?=$record->total_usage_string(); ?>
</td>
<td>
<?= number_format($record->get_usage_limit_mb(), 2) ?> MB
<?=$record->get_usage_limit_string(); ?>
</td>
</tr>
<? endforeach ?>

View File

@ -72,6 +72,28 @@ class rwinfo_block_Core {
}
// rWatcher Edit:
if (!$theme->item->is_album()) {
// Calculate file size.
$filesize_unit = array("B","kB","MB","GB","TB","PB","EB","ZB","YB");
$item_filesize = filesize($theme->item->file_path());
$unit_counter = 0;
while ($item_filesize >= 1024) {
$item_filesize = $item_filesize / 1024;
$unit_counter++;
}
$item_filesize = number_format($item_filesize, 2) . " " . $filesize_unit[$unit_counter];
$info["file_size"] = array(
"label" => t("File size:"),
"value" => $item_filesize
);
// Display photo/video resolution.
$info["file_resolution"] = array(
"label" => t("Resolution:"),
"value" => $theme->item->width . " x " . $theme->item->height . " " . t("pixels")
);
}
//if ($theme->item->captured && module::get_var("rwinfo", "show_captured")) {
// $info["captured"] = array(
// "label" => t("Captured:"),