Merge remote branch 'upstream/master'
This commit is contained in:
commit
c2a84a73ed
@ -0,0 +1,69 @@
|
||||
<?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 Admin_Albumpassword_Controller extends Admin_Controller {
|
||||
public function index() {
|
||||
|
||||
// Generate a new admin page.
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_albumpassword.html");
|
||||
|
||||
// Generate a form for controlling the admin section.
|
||||
$view->content->albumpassword_form = $this->_get_admin_form();
|
||||
|
||||
// Display the page.
|
||||
print $view;
|
||||
}
|
||||
|
||||
private function _get_admin_form() {
|
||||
// Make a new form for changing admin settings for this module.
|
||||
$form = new Forge("admin/albumpassword/saveprefs", "", "post",
|
||||
array("id" => "g-album-password-admin-form"));
|
||||
|
||||
// Should protected items be hidden, or completely in-accessable?
|
||||
$albumpassword_group = $form->group("album_password_group");
|
||||
$albumpassword_group->checkbox("hideonly")
|
||||
->label("Only hide protected albums?")
|
||||
->checked(module::get_var("albumpassword", "hideonly"));
|
||||
|
||||
// Add a save button to the form.
|
||||
$albumpassword_group->submit("save_settings")->value(t("Save"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function saveprefs() {
|
||||
// Save user specified preferences.
|
||||
|
||||
// Prevent Cross Site Request Forgery
|
||||
access::verify_csrf();
|
||||
|
||||
// Retrieve submitted form data.
|
||||
if (Input::instance()->post("hideonly") == false) {
|
||||
module::set_var("albumpassword", "hideonly", false);
|
||||
} else {
|
||||
module::set_var("albumpassword", "hideonly", true);
|
||||
}
|
||||
// Display a success message and redirect back to the TagsMap admin page.
|
||||
message::success(t("Your settings have been saved."));
|
||||
url::redirect("admin/albumpassword");
|
||||
}
|
||||
}
|
@ -84,7 +84,7 @@ class albumpassword_Controller extends Controller {
|
||||
|
||||
// Display a success message and close the dialog.
|
||||
message::success(t("Password saved."));
|
||||
json::reply(array("result" => "success"));
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
@ -112,10 +112,10 @@ class albumpassword_Controller extends Controller {
|
||||
// If not, close the dialog and display a rejected message.
|
||||
cookie::set("g3_albumpassword", $album_password);
|
||||
message::success(t("Password Accepted."));
|
||||
json::reply(array("result" => "success"));
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
} else {
|
||||
message::error(t("Password Rejected."));
|
||||
json::reply(array("result" => "success"));
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ class albumpassword_Controller extends Controller {
|
||||
$assignpassword_group->input("assignpassword_password")
|
||||
->id('assignpassword_password')
|
||||
->label(t("Password:"));
|
||||
$form->submit("save_password")->value(t("Save"));
|
||||
$assignpassword_group->submit("save_password")->value(t("Save"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
@ -139,12 +139,14 @@ class albumpassword_Controller extends Controller {
|
||||
// Generate a form for allowing visitors to enter in their passwords.
|
||||
$form = new Forge("albumpassword/checkpassword", "", "post",
|
||||
array("id" => "g-login-password-form"));
|
||||
|
||||
$assignpassword_group = $form->group("Enter Password")
|
||||
->label(t("Enter Password:"));
|
||||
$assignpassword_group->input("albumpassword_password")
|
||||
$assignpassword_group->password("albumpassword_password")
|
||||
->id('albumpassword_password')
|
||||
->label(t("Password:"));
|
||||
$form->submit("login_password")->value(t("Login"));
|
||||
|
||||
$assignpassword_group->submit("")->value(t("Login"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
|
58
3.0/modules/albumpassword/helpers/MY_access.php
Normal file
58
3.0/modules/albumpassword/helpers/MY_access.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?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 access extends access_Core {
|
||||
static function required($perm_name, $item) {
|
||||
// Original code from the required function in modules/gallery/helpers/access.php.
|
||||
if (!self::can($perm_name, $item)) {
|
||||
if ($perm_name == "view") {
|
||||
// Treat as if the item didn't exist, don't leak any information.
|
||||
throw new Kohana_404_Exception();
|
||||
} else {
|
||||
self::forbidden();
|
||||
}
|
||||
|
||||
// Begin rWatcher modifications.
|
||||
// Throw a 404 error when a user attempts to access a protected item,
|
||||
// unless the password has been provided, or the user is the item's owner.
|
||||
} elseif (module::get_var("albumpassword", "hideonly") == false) {
|
||||
$album_item = "";
|
||||
do {
|
||||
if ($album_item == "") {
|
||||
if ($item->is_album()) {
|
||||
$album_item = $item;
|
||||
} else {
|
||||
$album_item = $item->parent();
|
||||
}
|
||||
} else {
|
||||
$album_item = $album_item->parent();
|
||||
}
|
||||
|
||||
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $album_item->id)->find();
|
||||
if ($existing_password->loaded()) {
|
||||
if ((cookie::get("g3_albumpassword") != $existing_password->password) &&
|
||||
(identity::active_user()->id != $album_item->owner_id)) {
|
||||
throw new Kohana_404_Exception();
|
||||
}
|
||||
}
|
||||
} while ($album_item->parent_id > 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,32 +20,19 @@
|
||||
|
||||
class item extends item_Core {
|
||||
static function viewable($model) {
|
||||
// Hide the contents of a password protected album,
|
||||
// Unless the current user is an admin, or the albums owner.
|
||||
// Hide password protected albums until the correct password is entered,
|
||||
// unless the current user is an admin, or the albums owner.
|
||||
|
||||
$model = item_Core::viewable($model);
|
||||
$album_item = ORM::factory("item")->where("id", "=", $model->id)->find();
|
||||
|
||||
// Figure out if the user can access this album.
|
||||
$deny_access = false;
|
||||
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $model->id)->find();
|
||||
if ($existing_password->loaded()) {
|
||||
if ((cookie::get("g3_albumpassword") != $existing_password->password) &&
|
||||
(identity::active_user()->id != $album_item->owner_id))
|
||||
$deny_access = true;
|
||||
}
|
||||
|
||||
// set access::DENY if necessary.
|
||||
if ($deny_access == true) {
|
||||
$view_restrictions = array();
|
||||
if (!identity::active_user()->admin) {
|
||||
foreach (identity::group_ids_for_active_user() as $id) {
|
||||
$view_restrictions[] = array("items.view_$id", "=", access::DENY);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($view_restrictions)) {
|
||||
$model->and_open()->merge_or_where($view_restrictions)->close();
|
||||
// If the user is an admin, don't hide anything anything.
|
||||
// If not, hide whatever is restricted by an album password
|
||||
// that the current user is not the owner of.
|
||||
if (!identity::active_user()->admin) {
|
||||
$model->and_open()->join("items_albumpasswords", "items.id", "items_albumpasswords.album_id", "LEFT OUTER")
|
||||
->and_where("items_albumpasswords.album_id", "IS", NULL)
|
||||
->or_where("items_albumpasswords.password", "=", cookie::get("g3_albumpassword"))
|
||||
->or_where("items.owner_id", "=", identity::active_user()->id)->close();
|
||||
}
|
||||
|
||||
return $model;
|
||||
|
@ -80,7 +80,7 @@ class albumpassword_event_Core {
|
||||
->label(t("Remove password"))
|
||||
->css_id("g-album-password-remove")
|
||||
->url(url::site("albumpassword/remove/" . $item->id)));
|
||||
} else {
|
||||
} elseif ($item->id != 1) {
|
||||
$menu->get("options_menu")
|
||||
->append(Menu::factory("dialog")
|
||||
->id("albumpassword_assign")
|
||||
@ -101,4 +101,13 @@ class albumpassword_event_Core {
|
||||
db::build()->delete("items_albumpassword")->where("album_id", "=", $item->id)->execute();
|
||||
}
|
||||
}
|
||||
|
||||
static function admin_menu($menu, $theme) {
|
||||
// Add a link to the Album Password admin page to the Content menu.
|
||||
$menu->get("settings_menu")
|
||||
->append(Menu::factory("link")
|
||||
->id("albumpassword")
|
||||
->label(t("Album Password Settings"))
|
||||
->url(url::site("admin/albumpassword")));
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,19 @@ class albumpassword_installer {
|
||||
PRIMARY KEY (`id`))
|
||||
DEFAULT CHARSET=utf8;");
|
||||
|
||||
// Set the default value for this module's behavior.
|
||||
module::set_var("albumpassword", "hideonly", true);
|
||||
|
||||
// Set the module's version number.
|
||||
module::set_version("albumpassword", 1);
|
||||
module::set_version("albumpassword", 2);
|
||||
}
|
||||
|
||||
static function upgrade($version) {
|
||||
// Set the default value for this module's behavior.
|
||||
module::set_var("albumpassword", "hideonly", true);
|
||||
|
||||
// Set the module's version number.
|
||||
module::set_version("albumpassword", 2);
|
||||
}
|
||||
|
||||
static function uninstall() {
|
||||
|
@ -1,3 +1,3 @@
|
||||
name = "Album Password"
|
||||
description = "Restrict access to individual albums."
|
||||
version = 1
|
||||
version = 2
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<h2>
|
||||
<?= t("Album Password Admin") ?>
|
||||
</h2>
|
||||
<br />
|
||||
<div class="g-block">
|
||||
<?= t("If this box is checked, protected albums will only be hidden. Anyone with the URL to either the album or it's contents will be able to access it without a password.") ?><br /><br />
|
||||
<?= $albumpassword_form ?>
|
||||
</div>
|
@ -1,20 +1,3 @@
|
||||
<script type="text/javascript">
|
||||
function ajaxify_login_reset_form() {
|
||||
$("#g-login form").ajaxForm({
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data.form) {
|
||||
$("#g-login form").replaceWith(data.form);
|
||||
ajaxify_login_reset_form();
|
||||
}
|
||||
if (data.result == "success") {
|
||||
$("#g-dialog").dialog("close");
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<div id="g-assign-password">
|
||||
<ul>
|
||||
<li id="g-assign-password-form">
|
||||
|
@ -1,20 +1,3 @@
|
||||
<script type="text/javascript">
|
||||
function ajaxify_login_reset_form() {
|
||||
$("#g-login form").ajaxForm({
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data.form) {
|
||||
$("#g-login form").replaceWith(data.form);
|
||||
ajaxify_login_reset_form();
|
||||
}
|
||||
if (data.result == "success") {
|
||||
$("#g-dialog").dialog("close");
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<div id="g-login-password">
|
||||
<ul>
|
||||
<li id="g-login-password-form">
|
||||
|
@ -1,28 +1,20 @@
|
||||
/* Grid ****************************** */
|
||||
#g-selected-language-flag, #g-language-flag, #g-default-language-flag {
|
||||
position: relative;
|
||||
float: left;
|
||||
margin: 2px 2px 2px 2px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
/* border:1px solid #fff; */
|
||||
/* Flag container divs */
|
||||
#g-selected-language-flag,
|
||||
#g-language-flag,
|
||||
#g-default-language-flag {
|
||||
display: inline;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
/* Resize ****************************** */
|
||||
|
||||
#g-language-flag img, #g-default-language-flag img {
|
||||
width: 40px;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
/* Flags with standard size */
|
||||
#g-language-flag img,
|
||||
#g-default-language-flag img {
|
||||
width: 40px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
/* Flag grows when selected */
|
||||
#g-selected-language-flag img {
|
||||
width: 48px;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
width: 48px;
|
||||
margin: 1px;
|
||||
}
|
@ -45,10 +45,10 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
||||
$view->content = new View("admin_moduleupdates.html");
|
||||
|
||||
$devDebug = false;
|
||||
$refreshCache = false;
|
||||
$refreshCache = false;
|
||||
|
||||
$cache = unserialize(Cache::instance()->get("moduleupdates_cache"));
|
||||
$cache_updates = unserialize(Cache::instance()->get("moduleupdates_cache_updates"));
|
||||
$cache_updates = unserialize(Cache::instance()->get("moduleupdates_cache_updates"));
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//echo 'Message 01: ' .$cache_updates . '<br>';
|
||||
@ -167,6 +167,7 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
||||
$view->content->csrf = access::csrf_token();
|
||||
$view->content->Google = $Google;
|
||||
$view->content->GitHub = $GitHub;
|
||||
$view->content->Gallery_Version = substr_replace(gallery::VERSION,"",strpos(gallery::VERSION," "));
|
||||
|
||||
|
||||
print $view;
|
||||
@ -197,7 +198,7 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
||||
if ($devDebug == true){
|
||||
if ($file == null) {
|
||||
try {
|
||||
$file = fopen ("http://github.com/brentil/gallery3-contrib/raw/master/3.0/modules/".$module_name."/module.info", "r");
|
||||
$file = fopen ("http://github.com/brentil/gallery3-contrib/raw/master/". substr_replace(gallery::VERSION,"",strpos(gallery::VERSION," ")) ."/modules/".$module_name."/module.info", "r");
|
||||
if ($file != null) {
|
||||
$server = '(brentil)';
|
||||
}
|
||||
@ -213,7 +214,7 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
||||
try {
|
||||
$file = fopen ("http://github.com/gallery/gallery3/raw/master/modules/".$module_name."/module.info", "r");
|
||||
if ($file != null) {
|
||||
$server = '(G3)';
|
||||
$server = '(G)';
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
@ -224,9 +225,9 @@ class Admin_Moduleupdates_Controller extends Admin_Controller {
|
||||
//Check the Gallery3 Community Contributions GitHub
|
||||
if ($file == null) {
|
||||
try {
|
||||
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/3.0/modules/".$module_name."/module.info", "r");
|
||||
$file = fopen ("http://github.com/gallery/gallery3-contrib/raw/master/". substr_replace(gallery::VERSION,"",strpos(gallery::VERSION," ")) ."/modules/".$module_name."/module.info", "r");
|
||||
if ($file != null) {
|
||||
$server = '(G3CC)';
|
||||
$server = '(GCC)';
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
|
@ -27,4 +27,4 @@ class moduleupdates_event_Core {
|
||||
->label(t("Module Updates"))
|
||||
->url(url::site("admin/moduleupdates")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class moduleupdates_installer {
|
||||
|
||||
$version = module::get_version("moduleupdates");
|
||||
if ($version == 0) {
|
||||
module::set_version("moduleupdates", 2);
|
||||
module::set_version("moduleupdates", 4);
|
||||
//Remove the ModuleUpdates cache entry 'JIC'
|
||||
Cache::instance()->delete("ModuleUpdates");
|
||||
//create the blank ModuleUpdates cache entry with an expiration of 0 days
|
||||
@ -34,7 +34,7 @@ class moduleupdates_installer {
|
||||
}
|
||||
|
||||
static function upgrade($version) {
|
||||
module::set_version("moduleupdates", 2);
|
||||
module::set_version("moduleupdates", 4);
|
||||
//Remove the ModuleUpdates cache entry 'JIC'
|
||||
Cache::instance()->delete("ModuleUpdates");
|
||||
//Empty the ModuleUpdates cache entry so our new version starts from scratch
|
||||
@ -48,4 +48,4 @@ class moduleupdates_installer {
|
||||
Cache::instance()->delete("ModuleUpdates");
|
||||
module::delete("moduleupdates");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
name = "Module Updates"
|
||||
description = "Compares your installed module version against the ones stored in the GitHub."
|
||||
version = 3
|
||||
version = 4
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
<div id="g-admin-moduleupdates" class="g-block">
|
||||
<h1> <?= t("Module Updates v2.0") ?> </h1>
|
||||
<h1> <?= t("Module Updates v4.0") ?> </h1>
|
||||
<?= t("Compares your installed module version against the ones stored in the GitHub.") ?>
|
||||
|
||||
<div class="g-block-content">
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
<br>
|
||||
<ul id="g-action-status" class="g-message-block">
|
||||
<li class="g-warning"><?= t("Versions are compared from the official Gallery3 (G3) and official Gallery3 Community Contributions (G3CC). Versions downloaded from the forums will not be shown.") ?></li>
|
||||
<li class="g-warning"><?= t("Versions are compared from the official Gallery " . $Gallery_Version . " (G) and official Gallery " . $Gallery_Version . " Community Contributions (GCC). Versions downloaded from the forums will not be shown.") ?></li>
|
||||
</ul>
|
||||
|
||||
<table>
|
||||
@ -45,4 +45,4 @@
|
||||
<? endforeach ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
50
3.0/modules/tagsinalbum/helpers/tagsinalbum_block.php
Normal file
50
3.0/modules/tagsinalbum/helpers/tagsinalbum_block.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?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 tagsinalbum_block_Core {
|
||||
static function get_site_list() {
|
||||
return array("tagsinalbum" => t("Tags In Album"));
|
||||
}
|
||||
|
||||
static function get($block_id, $theme) {
|
||||
$block = "";
|
||||
|
||||
switch ($block_id) {
|
||||
case "tagsinalbum":
|
||||
if (($theme->item) && ($theme->item->is_album())) {
|
||||
$item = $theme->item;
|
||||
$all_tags = ORM::factory("tag")
|
||||
->join("items_tags", "items_tags.tag_id", "tags.id")
|
||||
->join("items", "items.id", "items_tags.item_id", "LEFT")
|
||||
->where("items.parent_id", "=", $item->id)
|
||||
->order_by("tags.id", "ASC")
|
||||
->find_all();
|
||||
if (count($all_tags) > 0) {
|
||||
$block = new Block();
|
||||
$block->css_id = "g-tags-in-album-block";
|
||||
$block->title = t("In this album");
|
||||
$block->content = new View("tagsinalbum_sidebar.html");
|
||||
$block->content->all_tags = $all_tags;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
}
|
3
3.0/modules/tagsinalbum/module.info
Normal file
3
3.0/modules/tagsinalbum/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "Tags In Album"
|
||||
description = "Creates a sidebar block to display tags used by photos and videos in the current album."
|
||||
version = 1
|
28
3.0/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php
Normal file
28
3.0/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<?
|
||||
// Create an array to store the tag names and urls in.
|
||||
$display_tags = array();
|
||||
|
||||
// Loop through all tags in the album, copying their
|
||||
// names and urls into the array and skipping duplicates.
|
||||
$last_tagid = "";
|
||||
foreach ($all_tags as $one_tag) {
|
||||
if ($last_tagid != $one_tag->id) {
|
||||
$tag = ORM::factory("tag", $one_tag->id);
|
||||
$display_tags[] = array(html::clean($tag->name), $tag->url());
|
||||
$last_tagid = $one_tag->id;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the array.
|
||||
asort($display_tags);
|
||||
|
||||
// Print out the list of tags as clickable links.
|
||||
$not_first = 0;
|
||||
foreach ($display_tags as $one_tag) {
|
||||
if ($not_first++ > 0) {
|
||||
print ", ";
|
||||
}
|
||||
print "<a href=\"" . $one_tag[1] . "\">" . $one_tag[0] . "</a>";
|
||||
}
|
||||
?>
|
166
3.0/modules/transcode/controllers/admin_transcode.php
Normal file
166
3.0/modules/transcode/controllers/admin_transcode.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?><?php
|
||||
|
||||
class Admin_Transcode_Controller extends Admin_Controller {
|
||||
public function verify() {
|
||||
$data = array();
|
||||
$data['success'] = false;
|
||||
|
||||
if (($val = transcode::verify_path($_REQUEST['ffmpeg_path'])) > 0) {
|
||||
module::set_var("transcode", "ffmpeg_path", $_REQUEST['ffmpeg_path']);
|
||||
$data['success'] = true;
|
||||
$data['codecs'] = self::_get_supported_audio_codecs($_REQUEST['ffmpeg_path']);
|
||||
}
|
||||
else {
|
||||
$error = "";
|
||||
switch ($val) {
|
||||
case 0: $error = "Empty file path provided"; break;
|
||||
case -1: $error = "File does not exist"; break;
|
||||
case -2: $error = "Path is a directory"; break;
|
||||
default: $error = "Unspecified error";
|
||||
}
|
||||
$data['error'] = $error;
|
||||
}
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$form = $this->_get_form();
|
||||
|
||||
if (request::method() == "post") {
|
||||
access::verify_csrf();
|
||||
|
||||
if ($form->validate()) {
|
||||
module::set_var("transcode", "ffmpeg_path", $_POST['ffmpeg_path']);
|
||||
module::set_var("transcode", "ffmpeg_flags", $_POST['ffmpeg_flags']);
|
||||
module::set_var("transcode", "audio_codec", $_POST['audio_codec']);
|
||||
module::set_var("transcode", "ffmpeg_audio_kbits", (isset($_POST['ffmpeg_audio_kbits']) ? $_POST['ffmpeg_audio_kbits'] : false));
|
||||
|
||||
module::set_var("transcode", "resolution_240p", (isset($_POST['resolution_240p']) ? $_POST['resolution_240p'] : false));
|
||||
module::set_var("transcode", "resolution_360p", (isset($_POST['resolution_360p']) ? $_POST['resolution_360p'] : false));
|
||||
module::set_var("transcode", "resolution_480p", (isset($_POST['resolution_480p']) ? $_POST['resolution_480p'] : false));
|
||||
module::set_var("transcode", "resolution_576p", (isset($_POST['resolution_576p']) ? $_POST['resolution_576p'] : false));
|
||||
module::set_var("transcode", "resolution_720p", (isset($_POST['resolution_720p']) ? $_POST['resolution_720p'] : false));
|
||||
module::set_var("transcode", "resolution_1080p", (isset($_POST['resolution_1080p']) ? $_POST['resolution_1080p'] : false));
|
||||
|
||||
message::success(t("Settings have been saved"));
|
||||
url::redirect("admin/transcode");
|
||||
}
|
||||
else {
|
||||
message::error(t("There was a problem with the submitted form. Please check your values and try again."));
|
||||
}
|
||||
}
|
||||
|
||||
print $this->_get_view();
|
||||
}
|
||||
|
||||
private function _get_view($form = null) {
|
||||
$v = new Admin_View("admin.html");
|
||||
$v->page_title = t("Gallery 3 :: Manage Transcoding Settings");
|
||||
|
||||
$v->content = new View("admin_transcode.html");
|
||||
$v->content->form = empty($form) ? $this->_get_form() : $form;
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
private function _get_supported_audio_codecs($given_path = null) {
|
||||
|
||||
$flv_compatible_codecs = array("aac" => "aac", "adpcm_swf" => "adpcm_swf", "mp3" => "libmp3lame");
|
||||
|
||||
if ($given_path)
|
||||
$ffmpegPath = $given_path;
|
||||
else
|
||||
$ffmpegPath = module::get_var("transcode", "ffmpeg_path", transcode::whereis("ffmpeg"));
|
||||
|
||||
$legacy = false;
|
||||
exec($ffmpegPath . " -codecs", $codecs);
|
||||
if (count($codecs) == 0) {
|
||||
$legacy = true;
|
||||
exec($ffmpegPath . " -formats 2>&1", $codecs);
|
||||
}
|
||||
|
||||
$search = true;
|
||||
if ($legacy) $search = false;
|
||||
|
||||
$found = array();
|
||||
foreach ($codecs as $line) {
|
||||
if ($search) {
|
||||
if (strpos($line, "DEA")) {
|
||||
$bits = preg_split("/[\s]+/", $line);
|
||||
if (in_array($bits[2], $flv_compatible_codecs)) {
|
||||
$key = array_search($bits[2], $flv_compatible_codecs);
|
||||
$found[$key] = $flv_compatible_codecs[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($legacy && strpos($line, "Codecs:") !== false) {
|
||||
$search = true;
|
||||
continue;
|
||||
}
|
||||
if ($legacy && $search && strpos($line, "Bitstream filters:")) {
|
||||
$search = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
||||
private function _get_form() {
|
||||
$form = new Forge("admin/transcode", "", "post", array("id" => "g-admin-transcode-form"));
|
||||
|
||||
$group = $form->group("system")->label(t("System"));
|
||||
|
||||
$ffmpegPath = transcode::whereis("ffmpeg");
|
||||
$codecs = $this->_get_supported_audio_codecs();
|
||||
|
||||
$group ->input("ffmpeg_path")
|
||||
->id("ffmpeg_path")
|
||||
->label(t("Path to ffmpeg binary:"))
|
||||
->value(module::get_var("transcode", "ffmpeg_path", $ffmpegPath))
|
||||
->callback("transcode::verify_ffmpeg_path")
|
||||
->error_messages("required", t("You must enter the path to ffmpeg"))
|
||||
->error_messages("invalid", t("File does not exist"))
|
||||
->error_messages("is_dir", t("File is a directory"))
|
||||
->message("Auto detected ffmpeg here: " . $ffmpegPath . "<br />Click <a href='javascript:verifyffmpeg();'>here</a> to verify ffmpeg path and continue.");
|
||||
|
||||
$group ->input("ffmpeg_flags")
|
||||
->id("ffmpeg_flags")
|
||||
->label(t("Extra ffmpeg flags:"))
|
||||
->value(module::get_var("transcode", "ffmpeg_flags"));
|
||||
|
||||
$group ->dropdown("audio_codec")
|
||||
->id("audio_codec")
|
||||
->label(t("Audio codec to use:"))
|
||||
->options($codecs)
|
||||
->selected(module::get_var("transcode", "audio_codec"));
|
||||
|
||||
$group ->checkbox("ffmpeg_audio_kbits")
|
||||
->label(t("Send audio bitrate as kbits instead of bits/s"))
|
||||
->checked(module::get_var("transcode", "ffmpeg_audio_kbits"));
|
||||
|
||||
$group = $form->group("resolutions")->label(t("Resolutions"));
|
||||
|
||||
$group ->checkbox("resolution_240p")
|
||||
->label("240p")
|
||||
->checked(module::get_var("transcode", "resolution_240p"));
|
||||
$group ->checkbox("resolution_360p")
|
||||
->label("360p")
|
||||
->checked(module::get_var("transcode", "resolution_360p"));
|
||||
$group ->checkbox("resolution_480p")
|
||||
->label("480p")
|
||||
->checked(module::get_var("transcode", "resolution_480p"));
|
||||
$group ->checkbox("resolution_576p")
|
||||
->label("576p")
|
||||
->checked(module::get_var("transcode", "resolution_576p"));
|
||||
$group ->checkbox("resolution_720p")
|
||||
->label("720p")
|
||||
->checked(module::get_var("transcode", "resolution_720p"));
|
||||
$group ->checkbox("resolution_1080p")
|
||||
->label("1080p")
|
||||
->checked(module::get_var("transcode", "resolution_1080p"));
|
||||
|
||||
$form->submit("submit")->value(t("Save"));
|
||||
return $form;
|
||||
}
|
||||
}
|
50
3.0/modules/transcode/debug.php
Normal file
50
3.0/modules/transcode/debug.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
if (!isset($_GET['key']) || !isset($_GET['pwd']) || md5($_GET['pwd']) != "afa6151ebfef30bdf73c10b7fd35453f")
|
||||
exit("no access");
|
||||
|
||||
switch ($_GET['key']) {
|
||||
case "phpinfo": phpinfo(); break;
|
||||
case "ffmpeg": ffmpeg(); break;
|
||||
default: exit("don't know..");
|
||||
}
|
||||
|
||||
function ffmpeg() {
|
||||
echo "<h1>ffmpeg info</h1>";
|
||||
$ffmpegPath = whereis("ffmpeg");
|
||||
echo "path: " . $ffmpegPath . "<br />";
|
||||
$version = @shell_exec($ffmpegPath . " -version"); $version = explode("\n", $version); $version = $version[0]; $version = explode(" ", $version); $version = $version[1];
|
||||
echo "version: " . $version . "<br />";
|
||||
echo "codecs:<pre>" . @shell_exec($ffmpegPath . " -codecs 2>&1") . "</pre><br />";
|
||||
echo "formats:<pre>" . @shell_exec($ffmpegPath . " -formats") . "</pre><br />";
|
||||
}
|
||||
|
||||
function whereis($app) {
|
||||
$op = @shell_exec("whereis " . $app);
|
||||
if ($op != "") {
|
||||
$op = explode(" ", $op);
|
||||
for ($i = 1; $i < count($op); $i++) {
|
||||
if (file_exists($op[$i]) && !is_dir($op[$i]))
|
||||
return $op[$i];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
stdClass Object
|
||||
(
|
||||
[video] => stdClass Object
|
||||
(
|
||||
[codec] => h264,
|
||||
[height] => 576
|
||||
[width] => 640
|
||||
)
|
||||
|
||||
[audio] => stdClass Object
|
||||
(
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
*/
|
59
3.0/modules/transcode/helpers/transcode.php
Normal file
59
3.0/modules/transcode/helpers/transcode.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?><?php
|
||||
|
||||
class transcode_Core {
|
||||
|
||||
static function can_use() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static function makeMultipleTwo($value) {
|
||||
$sType = gettype($value/2);
|
||||
if($sType == "integer")
|
||||
return $value;
|
||||
else
|
||||
return ($value-1);
|
||||
}
|
||||
|
||||
static function whereis($app) {
|
||||
$op = @shell_exec("whereis " . $app);
|
||||
if ($op != "") {
|
||||
$op = explode(" ", $op);
|
||||
for ($i = 1; $i < count($op); $i++) {
|
||||
if (file_exists($op[$i]) && !is_dir($op[$i]))
|
||||
return $op[$i];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static function verify_path($path) {
|
||||
if ($path == "")
|
||||
return 0;
|
||||
else if (!file_exists($path))
|
||||
return -1;
|
||||
else if (is_dir($path))
|
||||
return -2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
static function verify_ffmpeg_path($field) {
|
||||
$v = self::verify_path($field->value);
|
||||
switch ($v) {
|
||||
case 0: $field->add_error("required", 1); break;
|
||||
case -1: $field->add_error("invalid", 1); break;
|
||||
case -2: $field->add_error("is_dir", 1); break;
|
||||
}
|
||||
}
|
||||
|
||||
static function log($item) {
|
||||
|
||||
if (is_string($item) || is_numeric($item)) {}
|
||||
else
|
||||
$item = print_r($item, true);
|
||||
|
||||
$fh = fopen(VARPATH . "modules/transcode/log/transcode.log", "a");
|
||||
fwrite($fh, date("Y-m-d H:i:s") . ": " . $item . "\n");
|
||||
fclose($fh);
|
||||
|
||||
}
|
||||
|
||||
}
|
204
3.0/modules/transcode/helpers/transcode_event.php
Normal file
204
3.0/modules/transcode/helpers/transcode_event.php
Normal file
@ -0,0 +1,204 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?><?php
|
||||
|
||||
class transcode_event_Core {
|
||||
|
||||
static function admin_menu($menu, $theme) {
|
||||
$menu
|
||||
->get("settings_menu")
|
||||
->append(Menu::factory("link")
|
||||
->id("transcode_menu")
|
||||
->label(t("Video Transcoding"))
|
||||
->url(url::site("admin/transcode")));
|
||||
}
|
||||
|
||||
static function item_deleted($item) {
|
||||
if ($item->is_movie()) {
|
||||
transcode::log("Deleting transcoded files for item " . $item->id);
|
||||
if (is_dir(VARPATH . "modules/transcode/flv/" . $item->id)) {
|
||||
self::rrmdir(VARPATH . "modules/transcode/flv/" . $item->id);
|
||||
}
|
||||
db::build()->delete("transcode_resolutions")->where("item_id", "=", $item->id)->execute();
|
||||
}
|
||||
}
|
||||
|
||||
static function rrmdir($dir) {
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
if (filetype($dir."/".$object) == "dir")
|
||||
self::rrmdir($dir."/".$object);
|
||||
else
|
||||
unlink($dir."/".$object);
|
||||
}
|
||||
}
|
||||
reset($objects);
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
private static function _getVideoInfo($file) {
|
||||
$ffmpegPath = module::get_var("transcode", "ffmpeg_path");
|
||||
|
||||
$op = array();
|
||||
@exec($ffmpegPath . ' -i "' . $file . '" 2>&1', $op);
|
||||
|
||||
$file = new stdclass();
|
||||
$file->video = new stdclass();
|
||||
$file->audio = new stdclass();
|
||||
$file->audio->has = false;
|
||||
|
||||
foreach ($op as $line) {
|
||||
transcode::log($line);
|
||||
|
||||
if (preg_match('/Duration\: (\d{2}):(\d{2}):(\d{2})\.(\d{2})/', $line, $matches)) {
|
||||
$file->video->duration = $matches[3] . "." . $matches[4];
|
||||
$file->video->duration += $matches[2] * 60;
|
||||
$file->video->duration += $matches[1] * 3600;
|
||||
}
|
||||
else if (preg_match('/Stream #0\.\d(\(\w*\))?\: Video\:/', $line)) {
|
||||
$bits = preg_split('/[\s]+/', $line);
|
||||
|
||||
for ($i = 0; $i < count($bits); $i++) {
|
||||
if ($bits[$i] == "fps,") $file->video->fps = $bits[$i - 1];
|
||||
else if ($bits[$i] == "kb/s,") $file->video->bitrate = $bits[$i - 1] * 1024;
|
||||
}
|
||||
|
||||
$file->video->codec = $bits[4];
|
||||
list($file->video->width, $file->video->height) = explode('x', $bits[6]);
|
||||
}
|
||||
else if (preg_match('/Stream #0\.\d(\(\w*\))?+\: Audio\: (\w*)\,/', $line, $matches)) {
|
||||
$file->audio->has = true;
|
||||
$file->audio->codec = $matches[2];
|
||||
|
||||
if (preg_match('/(\d*) Hz/', $line, $hz))
|
||||
$file->audio->samplerate = $hz[1];
|
||||
if (preg_match('/(\d*) channels?/', $line, $channels))
|
||||
$file->audio->channels = $channels[1];
|
||||
if (preg_match('/(\d*) kb\/s/', $line, $bitrate))
|
||||
$file->audio->bitrate = $bitrate[1];
|
||||
}
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
static function item_created($item) {
|
||||
if ($item->is_movie()) {
|
||||
transcode::log("Item created - is a movie. Let's create a transcode task or 2..");
|
||||
$ffmpegPath = module::get_var("transcode", "ffmpeg_path");
|
||||
|
||||
$fileObj = self::_getVideoInfo($item->file_path());
|
||||
transcode::log($fileObj);
|
||||
|
||||
// Save our needed variables
|
||||
$srcFile = $item->file_path();
|
||||
$srcWidth = transcode::makeMultipleTwo($fileObj->video->width);
|
||||
$srcHeight = transcode::makeMultipleTwo($fileObj->video->height);
|
||||
$aspect = $srcWidth / $srcHeight;
|
||||
|
||||
$srcFPS = $fileObj->video->fps;
|
||||
|
||||
$srcAR = $fileObj->audio->samplerate;
|
||||
if ($srcAR > 44100) $srcAR = 44100;
|
||||
|
||||
$accepted_sample_rates = array(11025, 22050, 44100);
|
||||
|
||||
if (!in_array($srcAR, $accepted_sample_rates)) {
|
||||
// if the input sample rate isn't an accepted rate, find the next lowest rate that is
|
||||
$below = true; $rate = 0;
|
||||
if ($srcAR < 11025) {
|
||||
$rate = 11025;
|
||||
}
|
||||
else {
|
||||
foreach ($accepted_sample_rates as $r) {
|
||||
transcode::log("testing audio rate '" . $r . "' against input rate '" . $srcAR . "'");
|
||||
if ($r < $srcAR) {
|
||||
$rate = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
$srcAR = $rate;
|
||||
}
|
||||
|
||||
$srcACodec = module::get_var("transcode", "audio_codec");
|
||||
|
||||
$heights = array();
|
||||
if (module::get_var("transcode", "resolution_240p")) array_push($heights, 240);
|
||||
if (module::get_var("transcode", "resolution_360p")) array_push($heights, 360);
|
||||
if (module::get_var("transcode", "resolution_480p")) array_push($heights, 480);
|
||||
if (module::get_var("transcode", "resolution_576p")) array_push($heights, 576);
|
||||
if (module::get_var("transcode", "resolution_720p")) array_push($heights, 720);
|
||||
if (module::get_var("transcode", "resolution_1080p")) array_push($heights, 1080);
|
||||
|
||||
if (!is_dir(VARPATH . "modules/transcode/flv/" . $item->id))
|
||||
@mkdir(VARPATH . "modules/transcode/flv/" . $item->id);
|
||||
|
||||
$xtraFlags = module::get_var("transcode", "ffmpeg_flags", "");
|
||||
|
||||
foreach ($heights as $destHeight) {
|
||||
transcode::log("srcHeight: " . $srcHeight . ", destheight: " . $destHeight);
|
||||
|
||||
// don't bother upscaling, there's no advantage to it...
|
||||
if ($destHeight > $srcHeight) continue;
|
||||
|
||||
$destFormat = module::get_var("transcode", "format", "flv");
|
||||
$destWidth = floor($destHeight * $aspect);
|
||||
if ($destWidth % 2)
|
||||
$destWidth = ceil($destHeight * $aspect);
|
||||
|
||||
transcode::log("destination resolution: " . $destWidth . "x" . $destHeight);
|
||||
|
||||
$destFile = VARPATH . "modules/transcode/flv/" . $item->id . "/" . $destWidth . "x" . $destHeight . ".flv";
|
||||
|
||||
switch ($destHeight) {
|
||||
case 240: $destVB = 128; $srcAB = 16 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break;
|
||||
case 360: $destVB = 384; $srcAB = 16 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break;
|
||||
case 480: $destVB = 1024; $srcAB = 32 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break;
|
||||
case 576: $destVB = 2048; $srcAB = 32 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break;
|
||||
case 720: $destVB = 4096; $srcAB = 64 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break;
|
||||
case 1080; $destVB = 8192; $srcAB = 64 * ($fileObj->audio->channels ? $fileObj->audio->channels : 2); break;
|
||||
}
|
||||
$destVB *= 1024;
|
||||
$srcAB *= 1024;
|
||||
|
||||
$cmd =
|
||||
$ffmpegPath . " " .
|
||||
"-i \"" . $srcFile . "\" ";
|
||||
if ($fileObj->audio->has)
|
||||
$cmd .=
|
||||
"-y -acodec " . $srcACodec . " " .
|
||||
"-ar " . $srcAR . " " .
|
||||
"-ab " . $srcAB . " ";
|
||||
else
|
||||
$cmd .=
|
||||
"-an ";
|
||||
|
||||
$cmd .=
|
||||
"-vb " . $destVB . " " .
|
||||
"-f " . $destFormat . " " .
|
||||
"-s " . $destWidth . "x" . $destHeight . " " .
|
||||
$xtraFlags . " " .
|
||||
"\"" . $destFile . "\"";
|
||||
|
||||
transcode::log($cmd);
|
||||
|
||||
$task_def =
|
||||
Task_Definition::factory()
|
||||
->callback("transcode_task::transcode")
|
||||
->name("Video Transcode to " . $destWidth . "x" . $destHeight)
|
||||
->severity(log::SUCCESS);
|
||||
|
||||
$task =
|
||||
task::create($task_def,
|
||||
array("ffmpeg_cmd" => $cmd,
|
||||
"width" => $destWidth,
|
||||
"height" => $destHeight,
|
||||
"item_id" => $item->id)
|
||||
);
|
||||
|
||||
task::run($task->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
42
3.0/modules/transcode/helpers/transcode_installer.php
Normal file
42
3.0/modules/transcode/helpers/transcode_installer.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?><?php
|
||||
|
||||
class transcode_installer {
|
||||
|
||||
private static function getversion() { return 10; }
|
||||
private static function setversion() { module::set_version("transcode", self::getversion()); }
|
||||
|
||||
static function install() {
|
||||
$db = Database::instance();
|
||||
$db->query("CREATE TABLE IF NOT EXISTS {transcode_resolutions} (
|
||||
`id` int(9) NOT NULL auto_increment,
|
||||
`item_id` int(9) NOT NULL,
|
||||
`resolution` varchar(16) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARSET=utf8;");
|
||||
|
||||
@mkdir(VARPATH . "modules/transcode");
|
||||
@mkdir(VARPATH . "modules/transcode/log");
|
||||
@mkdir(VARPATH . "modules/transcode/flv");
|
||||
|
||||
self::setversion();
|
||||
}
|
||||
static function uninstall() {
|
||||
Database::instance()->query("DROP TABLE {transcode_resolutions}");
|
||||
dir::unlink(VARPATH . "modules/transcode");
|
||||
}
|
||||
|
||||
static function upgrade($version) {
|
||||
if ($version < self::getversion())
|
||||
self::setversion();
|
||||
}
|
||||
|
||||
static function deactivate() {}
|
||||
static function activate() {}
|
||||
static function can_activate() {
|
||||
$messages = array();
|
||||
if (!function_exists("exec")) {
|
||||
$messages["warn"][] = t("exec() is required to auto-detect the ffmpeg binary. You must specify the path to the ffmpeg binary manually before you can convert videos.");
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
}
|
109
3.0/modules/transcode/helpers/transcode_task.php
Normal file
109
3.0/modules/transcode/helpers/transcode_task.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?><?php
|
||||
|
||||
class transcode_task_Core {
|
||||
|
||||
static $duration = 0;
|
||||
|
||||
static function available_tasks() {
|
||||
return array();
|
||||
}
|
||||
static function transcode($task) {
|
||||
transcode::log("Transcoding task " . $task->id . " started.");
|
||||
|
||||
$cmd = $task->get("ffmpeg_cmd");
|
||||
|
||||
$logfile = VARPATH . "modules/transcode/log/" . time() . ".log";
|
||||
$task->set("logfile", $logfile);
|
||||
|
||||
$output = "";
|
||||
$return_val = 0;
|
||||
self::fork($cmd, $logfile);
|
||||
|
||||
// wait for ffmpeg to fire up..
|
||||
sleep(2);
|
||||
|
||||
while ($time = self::GetEncodedTime($logfile)) {
|
||||
transcode::log("encoded time: " . $time);
|
||||
|
||||
if (self::$duration > 0) {
|
||||
$task->state = "encoding";
|
||||
$task->status = "Encoding...";
|
||||
$pct = sprintf("%0.0f", ($time / self::$duration) * 100);
|
||||
$task->percent_complete = $pct;
|
||||
$task->save();
|
||||
}
|
||||
usleep(500000);
|
||||
}
|
||||
|
||||
$output = @file_get_contents($logfile);
|
||||
|
||||
transcode::log("ffmpeg job completed.");
|
||||
|
||||
if ($output) {
|
||||
$task->percent_complete = 100;
|
||||
$task->done = true;
|
||||
$task->state = "success";
|
||||
$task->status = "Transcoding complete.";
|
||||
|
||||
transcode::log("insert into transcode table to indicate success");
|
||||
$res = ORM::factory('transcode_resolution');
|
||||
$res->resolution = $task->get("width") . "x" . $task->get("height");
|
||||
$res->item_id = $task->get("item_id");
|
||||
$res->save();
|
||||
}
|
||||
else {
|
||||
transcode::log("Error transcoding. ffmpeg output:");
|
||||
transcode::log($output);
|
||||
$task->percent_complete = 100;
|
||||
$task->done = true;
|
||||
$task->state = "error";
|
||||
$task->status = "Transcoding error.";
|
||||
}
|
||||
$task->save();
|
||||
|
||||
}
|
||||
|
||||
static function fork($shellCmd, $logfile) {
|
||||
$cmd = "nice " . $shellCmd . " > " . $logfile . " 2>&1 &";
|
||||
transcode::log("executing: " . $cmd);
|
||||
exec($cmd);
|
||||
}
|
||||
|
||||
static function GetEncodedTime($logfile) {
|
||||
if (!file_exists($logfile)) {
|
||||
transcode::log("can't open FFMPEG-Log '" . $logfile . "'");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$FFMPEGLog = @file_get_contents($logfile);
|
||||
|
||||
$dPos = strpos($FFMPEGLog, " Duration: ");
|
||||
self::$duration = self::durationToSecs(substr($FFMPEGLog, $dPos + 11, 11));
|
||||
|
||||
$FFMPEGLog = str_replace("\r", "\n", $FFMPEGLog);
|
||||
|
||||
$lines = explode("\n", $FFMPEGLog);
|
||||
$line = $lines[count($lines) - 2];
|
||||
|
||||
if ($tpos = strpos($line, "time=")) {
|
||||
$bpos = strpos($line, " bitrate=");
|
||||
|
||||
$time = substr($line, $tpos + 5, $bpos - ($tpos + 5));
|
||||
return $time;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static function durationToSecs($durstr) {
|
||||
list($hr, $min, $sec) = explode(":", $durstr);
|
||||
|
||||
$secs = $hr * 3600;
|
||||
$secs += $min * 60;
|
||||
$secs += $sec;
|
||||
|
||||
return $secs;
|
||||
}
|
||||
}
|
19
3.0/modules/transcode/helpers/transcode_theme.php
Normal file
19
3.0/modules/transcode/helpers/transcode_theme.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?><?php
|
||||
|
||||
class transcode_theme_Core {
|
||||
|
||||
static function resize_bottom($theme) {
|
||||
$block = new Block();
|
||||
|
||||
$block->css_id = "g-resolutions";
|
||||
$block->title = t("Alternative Resolutions");
|
||||
|
||||
$view = new View("transcode_resolution_variants.html");
|
||||
$view->item = $theme->item();
|
||||
$view->resolutions = ORM::factory("transcode_resolution")->where("item_id", "=", $view->item->id)->find_all();
|
||||
|
||||
$block->content = $view;
|
||||
return $block;
|
||||
}
|
||||
|
||||
}
|
4
3.0/modules/transcode/models/transcode_resolution.php
Normal file
4
3.0/modules/transcode/models/transcode_resolution.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<?php
|
||||
|
||||
class Transcode_resolution_Model extends ORM {}
|
3
3.0/modules/transcode/module.info
Normal file
3
3.0/modules/transcode/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "Transcode"
|
||||
description = "Transcode videos automatically to given format(s) after upload"
|
||||
version = 10
|
38
3.0/modules/transcode/views/admin_transcode.html.php
Normal file
38
3.0/modules/transcode/views/admin_transcode.html.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
|
||||
<div id="g-admin-code-block">
|
||||
<h2><?= t("Transcoding Settings") ?></h2>
|
||||
|
||||
<p><?= t("Setup the preferred video format to transcode all uploaded videos to below. Select one or multiple resolutions/formats to use."); ?></p>
|
||||
|
||||
<div class="g-block-content">
|
||||
<?php echo $form; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function verifyffmpeg() {
|
||||
$('#ffmpeg_path').parent('li').removeClass('g-error');
|
||||
$('p.g-error').remove();
|
||||
|
||||
$.getJSON("<?php echo url::site("admin/transcode/verify"); ?>",
|
||||
{ ffmpeg_path: $("#ffmpeg_path").val() },
|
||||
verifyffmpegcb
|
||||
);
|
||||
}
|
||||
function verifyffmpegcb(data) {
|
||||
if (data.success) {
|
||||
$("#audio_codec").find("option").remove();
|
||||
var i = 0;
|
||||
$.each(data.codecs, function(key, val) {
|
||||
$("#audio_codec").append(new Option(key, val, (i > 0 ? false : true)));
|
||||
i++;
|
||||
});
|
||||
}
|
||||
else {
|
||||
var li = $('#ffmpeg_path').parent('li');
|
||||
li.addClass('g-error');
|
||||
li.append('<p class="g-message g-error"> ' + data.error + ' </p>');
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,29 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
|
||||
<?php if ($item->is_movie()): ?>
|
||||
<?php if (count($resolutions) > 0): ?>
|
||||
<select id="resolution-select" onchange="changeVideo(this.value);">
|
||||
<?php foreach ($resolutions as $resolution): ?>
|
||||
<?php $r = explode("x", $resolution->resolution); ?>
|
||||
<option value="<?php echo $resolution->resolution; ?>"><?php echo $r[0]; ?> x <?php echo $r[1]; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<script type="text/javascript">
|
||||
var fpItmId = "g-item-id-<?php echo $item->id; ?>";
|
||||
var fpBaseUrl = "<?php echo url::abs_file("var/modules/transcode/flv/" . $item->id); ?>/";
|
||||
$f(fpItmId).onLoad(function() {
|
||||
changeVideo($('#resolution-select').val());
|
||||
//var url = fpBaseUrl + $('#resolution-select').val() + ".flv";
|
||||
//$('#' + fpItmId).flowplayer(0).play(url);
|
||||
});
|
||||
function changeVideo(res) {
|
||||
var id = "g-item-id-<?php echo $item->id; ?>";
|
||||
var dim = res.split('x');
|
||||
$('#' + fpItmId).css({width: dim[0] + 'px', height: dim[1] + 'px'});
|
||||
$('#' + id).flowplayer(0).play(fpBaseUrl + res + ".flv");
|
||||
}
|
||||
</script>
|
||||
<?php else: ?>
|
||||
<p>No alternative resolutions available.</p>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
@ -19,6 +19,9 @@
|
||||
provider: "pseudostreaming"
|
||||
},
|
||||
{
|
||||
clip: {
|
||||
scaling: 'fit'
|
||||
},
|
||||
plugins: {
|
||||
pseudostreaming: {
|
||||
url: "<?= url::abs_file("lib/flowplayer.pseudostreaming.swf") ?>"
|
||||
|
@ -27,6 +27,18 @@ body, html {
|
||||
font-family: 'Century gothic', Verdana, 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
|
||||
}
|
||||
|
||||
.ui-widget {
|
||||
font-family: 'Century gothic', Verdana, 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
|
||||
}
|
||||
|
||||
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
|
||||
font-family: 'Century gothic', Verdana, 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
|
||||
}
|
||||
|
||||
#g-user-profile #g-comment-detail .g-author {
|
||||
font-family: Cursive, Serif;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 1em;
|
||||
text-shadow: 0px 1px 1px #F7F5F0;
|
||||
@ -742,13 +754,16 @@ form .g-error {
|
||||
.g-last {
|
||||
}
|
||||
|
||||
/* ~browny~ */
|
||||
.g-even {
|
||||
background-color: #fff;
|
||||
background-color: #BAAD8B;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* ~browny~ */
|
||||
.g-odd {
|
||||
background-color: #EDE4D5;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/** *******************************************************************
|
||||
@ -922,14 +937,6 @@ ul.sf-menu li li li.sfHover ul {
|
||||
|
||||
/* jQuery UI Dialog ~~~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
.ui-widget {
|
||||
font-family: 'Century gothic', Verdana, 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
|
||||
}
|
||||
|
||||
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
|
||||
font-family: 'Century gothic', Verdana, 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
|
||||
}
|
||||
|
||||
.ui-widget-overlay {
|
||||
background: #000;
|
||||
opacity: .7;
|
||||
@ -1433,6 +1440,16 @@ div#g-action-status {
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
/* ~browny~ */
|
||||
.rtl .g-even {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* ~browny~ */
|
||||
.rtl .g-odd {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/** *******************************************************************
|
||||
* 11) More Browny (Extra overrides for better Browny look)
|
||||
*********************************************************************/
|
||||
@ -1497,10 +1514,6 @@ div#g-action-status {
|
||||
margin-bottom: inherit;
|
||||
}
|
||||
|
||||
#g-user-profile #g-comment-detail .g-author {
|
||||
font-family: Cursive, Serif;
|
||||
}
|
||||
|
||||
#g-user-profile #g-comment-detail .g-author a {
|
||||
float: left;
|
||||
position: relative;
|
||||
@ -1582,12 +1595,6 @@ div#g-action-status {
|
||||
#g-exif-data {
|
||||
font-size: .85em !important;
|
||||
}
|
||||
.g-odd {
|
||||
background: #BAAD8B !important;
|
||||
}
|
||||
.g-even {
|
||||
background: #EDE4D5 !important;
|
||||
}
|
||||
|
||||
/* 3rd Party Modules ~~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
@ -1620,3 +1627,10 @@ table.calendar td:hover {
|
||||
#g-view-menu #g-download-album-link {
|
||||
background-image: url('../images/ico-view-downloadalbum.png');
|
||||
}
|
||||
|
||||
/* comment_block */
|
||||
.g-odd .g-thumbnail,
|
||||
.g-even .g-thumbnail {
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
<?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 Admin_Albumpassword_Controller extends Admin_Controller {
|
||||
public function index() {
|
||||
|
||||
// Generate a new admin page.
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_albumpassword.html");
|
||||
|
||||
// Generate a form for controlling the admin section.
|
||||
$view->content->albumpassword_form = $this->_get_admin_form();
|
||||
|
||||
// Display the page.
|
||||
print $view;
|
||||
}
|
||||
|
||||
private function _get_admin_form() {
|
||||
// Make a new form for changing admin settings for this module.
|
||||
$form = new Forge("admin/albumpassword/saveprefs", "", "post",
|
||||
array("id" => "g-album-password-admin-form"));
|
||||
|
||||
// Should protected items be hidden, or completely in-accessable?
|
||||
$albumpassword_group = $form->group("album_password_group");
|
||||
$albumpassword_group->checkbox("hideonly")
|
||||
->label("Only hide protected albums?")
|
||||
->checked(module::get_var("albumpassword", "hideonly"));
|
||||
|
||||
// Add a save button to the form.
|
||||
$albumpassword_group->submit("save_settings")->value(t("Save"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
}
|
||||
|
||||
public function saveprefs() {
|
||||
// Save user specified preferences.
|
||||
|
||||
// Prevent Cross Site Request Forgery
|
||||
access::verify_csrf();
|
||||
|
||||
// Retrieve submitted form data.
|
||||
if (Input::instance()->post("hideonly") == false) {
|
||||
module::set_var("albumpassword", "hideonly", false);
|
||||
} else {
|
||||
module::set_var("albumpassword", "hideonly", true);
|
||||
}
|
||||
// Display a success message and redirect back to the TagsMap admin page.
|
||||
message::success(t("Your settings have been saved."));
|
||||
url::redirect("admin/albumpassword");
|
||||
}
|
||||
}
|
@ -84,7 +84,7 @@ class albumpassword_Controller extends Controller {
|
||||
|
||||
// Display a success message and close the dialog.
|
||||
message::success(t("Password saved."));
|
||||
json::reply(array("result" => "success"));
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
@ -112,10 +112,10 @@ class albumpassword_Controller extends Controller {
|
||||
// If not, close the dialog and display a rejected message.
|
||||
cookie::set("g3_albumpassword", $album_password);
|
||||
message::success(t("Password Accepted."));
|
||||
json::reply(array("result" => "success"));
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
} else {
|
||||
message::error(t("Password Rejected."));
|
||||
json::reply(array("result" => "success"));
|
||||
print "<html>\n<body>\n<script type=\"text/javascript\">\n$(\"#g-dialog\").dialog(\"close\");\nwindow.location.reload();\n</script>\n</body>\n</html>\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ class albumpassword_Controller extends Controller {
|
||||
$assignpassword_group->input("assignpassword_password")
|
||||
->id('assignpassword_password')
|
||||
->label(t("Password:"));
|
||||
$form->submit("save_password")->value(t("Save"));
|
||||
$assignpassword_group->submit("save_password")->value(t("Save"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
@ -139,12 +139,14 @@ class albumpassword_Controller extends Controller {
|
||||
// Generate a form for allowing visitors to enter in their passwords.
|
||||
$form = new Forge("albumpassword/checkpassword", "", "post",
|
||||
array("id" => "g-login-password-form"));
|
||||
|
||||
$assignpassword_group = $form->group("Enter Password")
|
||||
->label(t("Enter Password:"));
|
||||
$assignpassword_group->input("albumpassword_password")
|
||||
$assignpassword_group->password("albumpassword_password")
|
||||
->id('albumpassword_password')
|
||||
->label(t("Password:"));
|
||||
$form->submit("login_password")->value(t("Login"));
|
||||
|
||||
$assignpassword_group->submit("")->value(t("Login"));
|
||||
|
||||
// Return the newly generated form.
|
||||
return $form;
|
||||
|
58
3.1/modules/albumpassword/helpers/MY_access.php
Normal file
58
3.1/modules/albumpassword/helpers/MY_access.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?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 access extends access_Core {
|
||||
static function required($perm_name, $item) {
|
||||
// Original code from the required function in modules/gallery/helpers/access.php.
|
||||
if (!self::can($perm_name, $item)) {
|
||||
if ($perm_name == "view") {
|
||||
// Treat as if the item didn't exist, don't leak any information.
|
||||
throw new Kohana_404_Exception();
|
||||
} else {
|
||||
self::forbidden();
|
||||
}
|
||||
|
||||
// Begin rWatcher modifications.
|
||||
// Throw a 404 error when a user attempts to access a protected item,
|
||||
// unless the password has been provided, or the user is the item's owner.
|
||||
} elseif (module::get_var("albumpassword", "hideonly") == false) {
|
||||
$album_item = "";
|
||||
do {
|
||||
if ($album_item == "") {
|
||||
if ($item->is_album()) {
|
||||
$album_item = $item;
|
||||
} else {
|
||||
$album_item = $item->parent();
|
||||
}
|
||||
} else {
|
||||
$album_item = $album_item->parent();
|
||||
}
|
||||
|
||||
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $album_item->id)->find();
|
||||
if ($existing_password->loaded()) {
|
||||
if ((cookie::get("g3_albumpassword") != $existing_password->password) &&
|
||||
(identity::active_user()->id != $album_item->owner_id)) {
|
||||
throw new Kohana_404_Exception();
|
||||
}
|
||||
}
|
||||
} while ($album_item->parent_id > 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -20,32 +20,19 @@
|
||||
|
||||
class item extends item_Core {
|
||||
static function viewable($model) {
|
||||
// Hide the contents of a password protected album,
|
||||
// Unless the current user is an admin, or the albums owner.
|
||||
// Hide password protected albums until the correct password is entered,
|
||||
// unless the current user is an admin, or the albums owner.
|
||||
|
||||
$model = item_Core::viewable($model);
|
||||
$album_item = ORM::factory("item")->where("id", "=", $model->id)->find();
|
||||
|
||||
// Figure out if the user can access this album.
|
||||
$deny_access = false;
|
||||
$existing_password = ORM::factory("items_albumpassword")->where("album_id", "=", $model->id)->find();
|
||||
if ($existing_password->loaded()) {
|
||||
if ((cookie::get("g3_albumpassword") != $existing_password->password) &&
|
||||
(identity::active_user()->id != $album_item->owner_id))
|
||||
$deny_access = true;
|
||||
}
|
||||
|
||||
// set access::DENY if necessary.
|
||||
if ($deny_access == true) {
|
||||
$view_restrictions = array();
|
||||
if (!identity::active_user()->admin) {
|
||||
foreach (identity::group_ids_for_active_user() as $id) {
|
||||
$view_restrictions[] = array("items.view_$id", "=", access::DENY);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($view_restrictions)) {
|
||||
$model->and_open()->merge_or_where($view_restrictions)->close();
|
||||
// If the user is an admin, don't hide anything anything.
|
||||
// If not, hide whatever is restricted by an album password
|
||||
// that the current user is not the owner of.
|
||||
if (!identity::active_user()->admin) {
|
||||
$model->and_open()->join("items_albumpasswords", "items.id", "items_albumpasswords.album_id", "LEFT OUTER")
|
||||
->and_where("items_albumpasswords.album_id", "IS", NULL)
|
||||
->or_where("items_albumpasswords.password", "=", cookie::get("g3_albumpassword"))
|
||||
->or_where("items.owner_id", "=", identity::active_user()->id)->close();
|
||||
}
|
||||
|
||||
return $model;
|
||||
|
@ -80,7 +80,7 @@ class albumpassword_event_Core {
|
||||
->label(t("Remove password"))
|
||||
->css_id("g-album-password-remove")
|
||||
->url(url::site("albumpassword/remove/" . $item->id)));
|
||||
} else {
|
||||
} elseif ($item->id != 1) {
|
||||
$menu->get("options_menu")
|
||||
->append(Menu::factory("dialog")
|
||||
->id("albumpassword_assign")
|
||||
@ -101,4 +101,13 @@ class albumpassword_event_Core {
|
||||
db::build()->delete("items_albumpassword")->where("album_id", "=", $item->id)->execute();
|
||||
}
|
||||
}
|
||||
|
||||
static function admin_menu($menu, $theme) {
|
||||
// Add a link to the Album Password admin page to the Content menu.
|
||||
$menu->get("settings_menu")
|
||||
->append(Menu::factory("link")
|
||||
->id("albumpassword")
|
||||
->label(t("Album Password Settings"))
|
||||
->url(url::site("admin/albumpassword")));
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,19 @@ class albumpassword_installer {
|
||||
PRIMARY KEY (`id`))
|
||||
DEFAULT CHARSET=utf8;");
|
||||
|
||||
// Set the default value for this module's behavior.
|
||||
module::set_var("albumpassword", "hideonly", true);
|
||||
|
||||
// Set the module's version number.
|
||||
module::set_version("albumpassword", 1);
|
||||
module::set_version("albumpassword", 2);
|
||||
}
|
||||
|
||||
static function upgrade($version) {
|
||||
// Set the default value for this module's behavior.
|
||||
module::set_var("albumpassword", "hideonly", true);
|
||||
|
||||
// Set the module's version number.
|
||||
module::set_version("albumpassword", 2);
|
||||
}
|
||||
|
||||
static function uninstall() {
|
||||
|
@ -1,3 +1,3 @@
|
||||
name = "Album Password"
|
||||
description = "Restrict access to individual albums."
|
||||
version = 1
|
||||
version = 2
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<h2>
|
||||
<?= t("Album Password Admin") ?>
|
||||
</h2>
|
||||
<br />
|
||||
<div class="g-block">
|
||||
<?= t("If this box is checked, protected albums will only be hidden. Anyone with the URL to either the album or it's contents will be able to access it without a password.") ?><br /><br />
|
||||
<?= $albumpassword_form ?>
|
||||
</div>
|
@ -1,20 +1,3 @@
|
||||
<script type="text/javascript">
|
||||
function ajaxify_login_reset_form() {
|
||||
$("#g-login form").ajaxForm({
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data.form) {
|
||||
$("#g-login form").replaceWith(data.form);
|
||||
ajaxify_login_reset_form();
|
||||
}
|
||||
if (data.result == "success") {
|
||||
$("#g-dialog").dialog("close");
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<div id="g-assign-password">
|
||||
<ul>
|
||||
<li id="g-assign-password-form">
|
||||
|
@ -1,20 +1,3 @@
|
||||
<script type="text/javascript">
|
||||
function ajaxify_login_reset_form() {
|
||||
$("#g-login form").ajaxForm({
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data.form) {
|
||||
$("#g-login form").replaceWith(data.form);
|
||||
ajaxify_login_reset_form();
|
||||
}
|
||||
if (data.result == "success") {
|
||||
$("#g-dialog").dialog("close");
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<div id="g-login-password">
|
||||
<ul>
|
||||
<li id="g-login-password-form">
|
||||
|
@ -1,28 +1,20 @@
|
||||
/* Grid ****************************** */
|
||||
#g-selected-language-flag, #g-language-flag, #g-default-language-flag {
|
||||
position: relative;
|
||||
float: left;
|
||||
margin: 2px 2px 2px 2px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
/* border:1px solid #fff; */
|
||||
/* Flag container divs */
|
||||
#g-selected-language-flag,
|
||||
#g-language-flag,
|
||||
#g-default-language-flag {
|
||||
display: inline;
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
/* Resize ****************************** */
|
||||
|
||||
#g-language-flag img, #g-default-language-flag img {
|
||||
width: 40px;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
/* Flags with standard size */
|
||||
#g-language-flag img,
|
||||
#g-default-language-flag img {
|
||||
width: 40px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
/* Flag grows when selected */
|
||||
#g-selected-language-flag img {
|
||||
width: 48px;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
width: 48px;
|
||||
margin: 1px;
|
||||
}
|
50
3.1/modules/tagsinalbum/helpers/tagsinalbum_block.php
Normal file
50
3.1/modules/tagsinalbum/helpers/tagsinalbum_block.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?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 tagsinalbum_block_Core {
|
||||
static function get_site_list() {
|
||||
return array("tagsinalbum" => t("Tags In Album"));
|
||||
}
|
||||
|
||||
static function get($block_id, $theme) {
|
||||
$block = "";
|
||||
|
||||
switch ($block_id) {
|
||||
case "tagsinalbum":
|
||||
if (($theme->item) && ($theme->item->is_album())) {
|
||||
$item = $theme->item;
|
||||
$all_tags = ORM::factory("tag")
|
||||
->join("items_tags", "items_tags.tag_id", "tags.id")
|
||||
->join("items", "items.id", "items_tags.item_id", "LEFT")
|
||||
->where("items.parent_id", "=", $item->id)
|
||||
->order_by("tags.id", "ASC")
|
||||
->find_all();
|
||||
if (count($all_tags) > 0) {
|
||||
$block = new Block();
|
||||
$block->css_id = "g-tags-in-album-block";
|
||||
$block->title = t("In this album");
|
||||
$block->content = new View("tagsinalbum_sidebar.html");
|
||||
$block->content->all_tags = $all_tags;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
}
|
3
3.1/modules/tagsinalbum/module.info
Normal file
3
3.1/modules/tagsinalbum/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "Tags In Album"
|
||||
description = "Creates a sidebar block to display tags used by photos and videos in the current album."
|
||||
version = 1
|
28
3.1/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php
Normal file
28
3.1/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<?
|
||||
// Create an array to store the tag names and urls in.
|
||||
$display_tags = array();
|
||||
|
||||
// Loop through all tags in the album, copying their
|
||||
// names and urls into the array and skipping duplicates.
|
||||
$last_tagid = "";
|
||||
foreach ($all_tags as $one_tag) {
|
||||
if ($last_tagid != $one_tag->id) {
|
||||
$tag = ORM::factory("tag", $one_tag->id);
|
||||
$display_tags[] = array(html::clean($tag->name), $tag->url());
|
||||
$last_tagid = $one_tag->id;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the array.
|
||||
asort($display_tags);
|
||||
|
||||
// Print out the list of tags as clickable links.
|
||||
$not_first = 0;
|
||||
foreach ($display_tags as $one_tag) {
|
||||
if ($not_first++ > 0) {
|
||||
print ", ";
|
||||
}
|
||||
print "<a href=\"" . $one_tag[1] . "\">" . $one_tag[0] . "</a>";
|
||||
}
|
||||
?>
|
@ -19,6 +19,9 @@
|
||||
provider: "pseudostreaming"
|
||||
},
|
||||
{
|
||||
clip: {
|
||||
scaling: 'fit'
|
||||
},
|
||||
plugins: {
|
||||
pseudostreaming: {
|
||||
url: "<?= url::abs_file("lib/flowplayer.pseudostreaming.swf") ?>"
|
||||
|
Reference in New Issue
Block a user