1
0

Complete re-write for Gallery 3.0.1 compatability.

This commit is contained in:
rWatcher 2011-04-22 00:33:11 -04:00
parent 30d9551dab
commit e2dc311221
40 changed files with 2849 additions and 339 deletions

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,10 +17,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher EDIT: This file used to be admin_server_add.php.
// All occurences of server_add have been replaced with videos.
class Admin_Videos_Controller extends Admin_Controller {
public function index() {
$view = new Admin_View("admin.html");
$view->page_title = t("Add videos from server");
$view->page_title = t("Add from server");
$view->content = new View("admin_videos.html");
$view->content->form = $this->_get_admin_form();
$paths = unserialize(module::get_var("videos", "authorized_paths", "a:0:{}"));

View File

@ -0,0 +1,144 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 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.
*/
/**
* Proxy access to files in var/albums and var/resizes, making sure that the session user has
* access to view these files.
*
* Security Philosophy: we do not use the information provided to find if the file exists on
* disk. We use this information only to locate the correct item in the database and then we
* *only* use information from the database to find and proxy the correct file. This way all user
* input is sanitized against the database before we perform any file I/O.
*/
class File_Proxy_Controller extends Controller {
const ALLOW_PRIVATE_GALLERY = true;
public function __call($function, $args) {
// request_uri: gallery3/var/albums/foo/bar.jpg?m=1234
$request_uri = rawurldecode(Input::instance()->server("REQUEST_URI"));
// get rid of query parameters
// request_uri: gallery3/var/albums/foo/bar.jpg
$request_uri = preg_replace("/\?.*/", "", $request_uri);
// var_uri: gallery3/var/
$var_uri = url::file("var/");
// Make sure that the request is for a file inside var
$offset = strpos(rawurldecode($request_uri), $var_uri);
if ($offset !== 0) {
throw new Kohana_404_Exception();
}
// file_uri: albums/foo/bar.jpg
$file_uri = substr($request_uri, strlen($var_uri));
// type: albums
// path: foo/bar.jpg
list ($type, $path) = explode("/", $file_uri, 2);
if ($type != "resizes" && $type != "albums" && $type != "thumbs") {
throw new Kohana_404_Exception();
}
// If the last element is .album.jpg, pop that off since it's not a real item
$path = preg_replace("|/.album.jpg$|", "", $path);
$item = item::find_by_path($path);
if (!$item->loaded()) {
// We didn't turn it up. If we're looking for a .jpg then it's it's possible that we're
// requesting the thumbnail for a movie. In that case, the .flv, .mp4 or .m4v file would
// have been converted to a .jpg. So try some alternate types:
if (preg_match('/.jpg$/', $path)) {
// rWatcher Mod: look for videos with file extensions supported by the videos module in addition to flv mp4 and m4v
// Original Line: foreach (array("flv", "mp4", "m4v") as $ext) {
foreach (array_merge(array("flv", "mp4", "m4v"), unserialize(module::get_var("videos", "allowed_extensions"))) as $ext) {
$movie_path = preg_replace('/.jpg$/', ".$ext", $path);
$item = item::find_by_path($movie_path);
if ($item->loaded()) {
break;
}
}
}
// rWatcher Mod:
// If we're looking for a .flv then it's it's possible that we're requesting a flash resize
// for a movie.
if (strtolower(substr($path, strlen($path)-4)) == ".flv") {
$movie_path = str_ireplace(".flv", "", $path);
$item = ORM::factory("item")->where("relative_path_cache", "=", $movie_path)->find();
}
// END rWatcher Mod
}
if (!$item->loaded()) {
throw new Kohana_404_Exception();
}
// Make sure we have access to the item
if (!access::can("view", $item)) {
throw new Kohana_404_Exception();
}
// Make sure we have view_full access to the original
if ($type == "albums" && !access::can("view_full", $item)) {
throw new Kohana_404_Exception();
}
// Don't try to load a directory
if ($type == "albums" && $item->is_album()) {
throw new Kohana_404_Exception();
}
if ($type == "albums") {
$file = $item->file_path();
} else if ($type == "resizes") {
$file = $item->resize_path();
// rWatcher MOD
// If the resize is for a movie, assume it needs a .flv extension.
if ($item->is_movie()) {
$file = $file . ".flv";
}
// End rWatcher MOD
} else {
$file = $item->thumb_path();
}
if (!file_exists($file)) {
throw new Kohana_404_Exception();
}
header("Content-Length: " . filesize($file));
header("Pragma:");
// Check that the content hasn't expired or it wasn't changed since cached
expires::check(2592000, $item->updated);
// We don't need to save the session for this request
Session::instance()->abort_save();
expires::set(2592000, $item->updated); // 30 days
// Dump out the image. If the item is a movie, then its thumbnail will be a JPG.
if ($item->is_movie() && $type != "albums") {
header("Content-Type: image/jpeg");
} else {
header("Content-Type: $item->mime_type");
}
Kohana::close_buffers(false);
readfile($file);
}
}

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,6 +17,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher Edit: This file used to be server_add.php.
// All occurences of server_add have been replaced with videos.
// Additional editing has also been done in three places to expand accepted file
// extensions and to create resizes and an extra db entry for items_videos.
class Videos_Controller extends Admin_Controller {
public function browse($id) {
$paths = unserialize(module::get_var("videos", "authorized_paths"));
@ -24,6 +30,12 @@ class Videos_Controller extends Admin_Controller {
$files[] = $path;
}
// Clean leftover task rows. There really should be support for this in the task framework
db::build()
->where("task_id", "NOT IN", db::build()->select("id")->from("tasks"))
->delete("videos_entries")
->execute();
$item = ORM::factory("item", $id);
$view = new View("videos_tree_dialog.html");
$view->item = $item;
@ -55,6 +67,7 @@ class Videos_Controller extends Admin_Controller {
}
if (!is_dir($file)) {
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
// rWatcher Edit
//if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4", "m4v"))) {
if (!in_array($ext, unserialize(module::get_var("videos", "allowed_extensions")))) {
continue;
@ -74,23 +87,28 @@ class Videos_Controller extends Admin_Controller {
}
/**
* Begin the task of adding files.
* Begin the task of adding photos.
*/
public function start() {
access::verify_csrf();
$item = ORM::factory("item", Input::instance()->get("item_id"));
foreach (Input::instance()->post("paths") as $path) {
if (videos::is_valid_path($path)) {
$paths[] = array($path, null);
}
}
$task_def = Task_Definition::factory()
->callback("Videos_Controller::add")
->description(t("Add videos from the local server"))
->description(t("Add photos or movies from the local server"))
->name(t("Add from server"));
$task = task::create($task_def, array("item_id" => $item->id, "queue" => $paths));
$task = task::create($task_def, array("item_id" => $item->id));
foreach (Input::instance()->post("paths") as $path) {
if (videos::is_valid_path($path)) {
$entry = ORM::factory("videos_entry");
$entry->path = $path;
$entry->is_directory = intval(is_dir($path));
$entry->parent_id = null;
$entry->task_id = $task->id;
$entry->save();
}
}
json::reply(
array("result" => "started",
@ -99,7 +117,7 @@ class Videos_Controller extends Admin_Controller {
}
/**
* Run the task of adding files
* Run the task of adding photos
*/
function run($task_id) {
access::verify_csrf();
@ -119,7 +137,7 @@ class Videos_Controller extends Admin_Controller {
/**
* This is the task code that adds photos and albums. It first examines all the target files
* and creates a set of Server_Add_File_Models, then runs through the list of models and adds
* and creates a set of Server_Add_Entry_Models, then runs through the list of models and adds
* them one at a time.
*/
static function add($task) {
@ -129,6 +147,7 @@ class Videos_Controller extends Admin_Controller {
switch ($mode) {
case "init":
$task->set("mode", "build-file-list");
$task->set("dirs_scanned", 0);
$task->percent_complete = 0;
$task->status = t("Starting up");
batch::start();
@ -137,59 +156,64 @@ class Videos_Controller extends Admin_Controller {
case "build-file-list": // 0% to 10%
// We can't fit an arbitrary number of paths in a task, so store them in a separate table.
// Don't use an iterator here because we can't get enough control over it when we're dealing
// with a deep hierarchy and we don't want to go over our time quota. The queue is in the
// form [path, parent_id] where the parent_id refers to another Server_Add_File_Model. We
// have this extra level of abstraction because we don't know its Item_Model id yet.
$queue = $task->get("queue");
// with a deep hierarchy and we don't want to go over our time quota.
$paths = unserialize(module::get_var("videos", "authorized_paths"));
$dirs_scanned = $task->get("dirs_scanned");
while (microtime(true) - $start < 0.5) {
// Process every directory that doesn't yet have a parent id, these are the
// paths that we're importing.
$entry = ORM::factory("videos_entry")
->where("task_id", "=", $task->id)
->where("is_directory", "=", 1)
->where("checked", "=", 0)
->order_by("id", "ASC")
->find();
while ($queue && microtime(true) - $start < 0.5) {
list($file, $parent_entry_id) = array_shift($queue);
// Ignore the staging directories as directories to be imported.
if (empty($paths[$file])) {
$entry = ORM::factory("videos_file");
$entry->task_id = $task->id;
$entry->file = $file;
$entry->parent_id = $parent_entry_id;
$entry->save();
$entry_id = $entry->id;
} else {
$entry_id = null;
}
$file = preg_quote($file);
foreach (glob("$file/*") as $child) {
if (is_dir($child)) {
$queue[] = array($child, $entry_id);
} else {
$ext = strtolower(pathinfo($child, PATHINFO_EXTENSION));
//if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4", "m4v")) &&
if (in_array($ext, unserialize(module::get_var("videos", "allowed_extensions"))) &&
filesize($child) > 0) {
$child_entry = ORM::factory("videos_file");
$child_entry->task_id = $task->id;
$child_entry->file = $child;
$child_entry->parent_id = $entry_id;
$child_entry->save();
}
if ($entry->loaded()) {
$child_paths = glob(preg_quote($entry->path) . "/*");
if (!$child_paths) {
$child_paths = glob("{$entry->path}/*");
}
foreach ($child_paths as $child_path) {
if (!is_dir($child_path)) {
$ext = strtolower(pathinfo($child_path, PATHINFO_EXTENSION));
// rWatcher Edit.
//if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4", "m4v")) ||
// !filesize($child_path)) {
if (!in_array($ext, unserialize(module::get_var("videos", "allowed_extensions"))) ||
!filesize($child_path)) {
// Not importable, skip it.
continue;
}
}
$child_entry = ORM::factory("videos_entry");
$child_entry->task_id = $task->id;
$child_entry->path = $child_path;
$child_entry->parent_id = $entry->id; // null if the parent was a staging dir
$child_entry->is_directory = is_dir($child_path);
$child_entry->save();
}
// We've processed this entry, mark it as done.
$entry->checked = 1;
$entry->save();
$dirs_scanned++;
}
}
// We have no idea how long this can take because we have no idea how deep the tree
// hierarchy rabbit hole goes. Leave ourselves room here for 100 iterations and don't go
// over 10% in percent_complete.
$task->set("queue", $queue);
$task->set("dirs_scanned", $dirs_scanned);
$task->percent_complete = min($task->percent_complete + 0.1, 10);
$task->status = t2(
"Found one file", "Found %count files",
ORM::factory("videos_file")->where("task_id", "=", $task->id)->count_all());
$task->status = t2("Scanned one directory", "Scanned %count directories", $dirs_scanned);
if (!$queue) {
if (!$entry->loaded()) {
$task->set("mode", "add-files");
$task->set(
"total_files",
ORM::factory("videos_file")->where("task_id", "=", $task->id)->count_all());
ORM::factory("videos_entry")->where("task_id", "=", $task->id)->count_all());
$task->percent_complete = 10;
}
break;
@ -201,7 +225,7 @@ class Videos_Controller extends Admin_Controller {
// Ordering by id ensures that we add them in the order that we created the entries, which
// will create albums first. Ignore entries which already have an Item_Model attached,
// they're done.
$entries = ORM::factory("videos_file")
$entries = ORM::factory("videos_entry")
->where("task_id", "=", $task->id)
->where("item_id", "IS", null)
->order_by("id", "ASC")
@ -220,43 +244,59 @@ class Videos_Controller extends Admin_Controller {
// Look up the parent item for this entry. By now it should exist, but if none was
// specified, then this belongs as a child of the current item.
$parent_entry = ORM::factory("videos_file", $entry->parent_id);
$parent_entry = ORM::factory("videos_entry", $entry->parent_id);
if (!$parent_entry->loaded()) {
$parent = ORM::factory("item", $task->get("item_id"));
} else {
$parent = ORM::factory("item", $parent_entry->item_id);
}
$name = basename($entry->file);
$name = basename($entry->path);
$title = item::convert_filename_to_title($name);
if (is_dir($entry->file)) {
if ($entry->is_directory) {
$album = ORM::factory("item");
$album->type = "album";
$album->parent_id = $parent->id;
$album->name = $name;
$album->title = $title;
$album->owner_id = $owner_id;
$album->sort_order = $parent->sort_order;
$album->sort_column = $parent->sort_column;
$album->save();
$entry->item_id = $album->id;
} else {
try {
$extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
if (in_array($extension, unserialize(module::get_var("videos", "allowed_extensions")))) {
if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) {
$photo = ORM::factory("item");
$photo->type = "photo";
$photo->parent_id = $parent->id;
$photo->set_data_file($entry->path);
$photo->name = $name;
$photo->title = $title;
$photo->owner_id = $owner_id;
$photo->save();
$entry->item_id = $photo->id;
// rWatcher EDIT
//} else if (in_array($extension, array("flv", "mp4", "m4v"))) {
} else if (in_array($extension, unserialize(module::get_var("videos", "allowed_extensions")))) {
$movie = ORM::factory("item");
$movie->type = "movie";
$movie->parent_id = $parent->id;
$movie->set_data_file($entry->file);
$movie->set_data_file($entry->path);
$movie->name = $name;
$movie->title = $title;
$movie->owner_id = $owner_id;
$movie->save();
$entry->item_id = $movie->id;
// rWatcher EDIT: Add record to items_video db.
$items_video = ORM::factory("items_video");
$items_video->item_id = $movie->id;
$items_video->save();
if (file_exists($entry->file . ".flv")) {
copy($entry->file . ".flv", $movie->resize_path() . ".flv");
list ($vid_width, $vid_height, $mime_type) = movie::get_file_metadata($entry->file . ".flv");
// rWatcher EDIT: Scan for flv resizes and copy to resize directory.
if (file_exists($entry->path . ".flv")) {
copy($entry->path . ".flv", $movie->resize_path() . ".flv");
list ($vid_width, $vid_height, $mime_type) = movie::get_file_metadata($entry->path . ".flv");
$movie->height = $vid_height;
$movie->width = $vid_width;
$movie->save();
@ -266,12 +306,12 @@ class Videos_Controller extends Admin_Controller {
// process. But just in, case.. set this to a non-null value so that we skip this
// entry.
$entry->item_id = 0;
$task->log("Skipping unknown file type: $entry->file");
$task->log("Skipping unknown file type: {$entry->path}");
}
} catch (Exception $e) {
// This can happen if a photo file is invalid, like a BMP masquerading as a .jpg
$entry->item_id = 0;
$task->log("Skipping invalid file: $entry->file");
$task->log("Skipping invalid file: {$entry->file}");
}
}
@ -290,12 +330,11 @@ class Videos_Controller extends Admin_Controller {
$task->done = true;
$task->state = "success";
$task->percent_complete = 100;
db::build()
->delete("videos_files")
ORM::factory("videos_entry")
->where("task_id", "=", $task->id)
->execute();
message::info(t2("Successfully added one file",
"Successfully added %count files",
->delete_all();
message::info(t2("Successfully added one photo / album",
"Successfully added %count photos / albums",
$task->get("completed_files")));
}
}

View File

@ -1,23 +1,23 @@
#g-server-add button {
#g-videos button {
margin-bottom: .5em;
}
#g-server-add-tree {
#g-videos-tree {
cursor: pointer;
padding-left: 4px;
width: 95%;
}
#g-server-add-tree li {
#g-videos-tree li {
padding: 0;
float: none;
}
#g-server-add-tree span.selected {
#g-videos-tree span.selected {
background: #ddd;
}
#g-server-add-tree {
#g-videos-tree {
border: 1px solid #ccc;
height: 20em;
overflow: auto;
@ -25,14 +25,14 @@
padding: .5em;
}
#g-server-add ul ul li {
#g-videos ul ul li {
padding-left: 1.2em;
}
#g-server-add-paths li .ui-icon {
#g-videos-paths li .ui-icon {
margin-top: .4em;
}
#g-server-add-admin-form .textbox {
#g-videos-admin-form .textbox {
width: 400px;
}

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,6 +17,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher edit: This file used to be server_add.php.
// All occurences of server_add have been replaced with videos.
class videos_Core {
static function check_config($paths=null) {
if ($paths === null) {

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,6 +17,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher Edit: This file used to be server_add_event.php.
// All occurences of server_add have been replaced with videos.
// Additionally, several new functions have been added.
class videos_event_Core {
static function admin_menu($menu, $theme) {
$menu->get("settings_menu")
@ -34,7 +38,7 @@ class videos_event_Core {
is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path())) {
$menu->get("add_menu")
->append(Menu::factory("dialog")
->id("videos")
->id("Videos")
->label(t("Add videos"))
->url(url::site("videos/browse/$item->id")));
}

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,36 +17,60 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher Edit: This file was server_add_installer.
// All occurences of server_add have been replaced with videos.
// The installer has been edited to create an additional table and module variable.
// The upgrader has been edited to skip everything before version 4, to keep version numbers in sync with server_add.
class videos_installer {
static function install() {
$db = Database::instance();
$db->query("CREATE TABLE {videos_files} (
$db->query("CREATE TABLE {videos_entries} (
`id` int(9) NOT NULL auto_increment,
`file` varchar(255) NOT NULL,
`checked` boolean default 0,
`is_directory` boolean default 0,
`item_id` int(9),
`parent_id` int(9),
`path` varchar(255) NOT NULL,
`task_id` int(9) NOT NULL,
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
// rWatcher Edit: My Table.
$db->query("CREATE TABLE {items_videos} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9) NOT NULL,
PRIMARY KEY (`id`),
KEY (`item_id`, `id`))
DEFAULT CHARSET=utf8;");
// rWatcher Edit: My Variable.
module::set_var("videos", "allowed_extensions", serialize(array("avi", "mpg", "mpeg", "mov", "wmv", "asf", "mts")));
module::set_version("videos", 1);
module::set_version("videos", 4);
videos::check_config();
}
static function upgrade($version) {
$db = Database::instance();
if ($version < 4) {
$db->query("DROP TABLE {videos_files}");
$db->query("CREATE TABLE {videos_entries} (
`id` int(9) NOT NULL auto_increment,
`checked` boolean default 0,
`is_directory` boolean default 0,
`item_id` int(9),
`parent_id` int(9),
`path` varchar(255) NOT NULL,
`task_id` int(9) NOT NULL,
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
module::set_version("videos", $version = 4);
}
}
static function deactivate() {
site_status::clear("videos_configuration");
}
static function uninstall() {
$db = Database::instance();
$db->query("DROP TABLE IF EXISTS {videos_files};");
$db->query("DROP TABLE IF EXISTS {items_videos};");
module::delete("videos");
}
}

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,6 +17,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher Edit: This file used to be server_add_theme.php.
// All occurences of server_add have been replaced with videos.
// Additionally, the head function has been reworked to provide a
// download link for unplayable videos and references to admin.js are now admin_videos.js.
class videos_theme_Core {
static function head($theme) {
$buf = "";
@ -30,27 +36,26 @@ class videos_theme_Core {
$items_video = ORM::factory("items_video")
->where("item_id", "=", $item->id)
->find();
if ($items_video->loaded()) {
$view = new View("videos_display_js.html");
//$view->embed_code = addslashes($embedded_video->embed_code);
return $buf . $view;
if (($items_video->loaded()) && (!file_exists($item->resize_path() . ".flv"))) {
$buf .= $theme->script("videos_download.js");
}
}
return $buf;
}
static function admin_head($theme) {
$buf = "";
if (strpos(Router::$current_uri, "admin/videos") !== false) {
$buf .= $theme->css("videos.css");
$buf .= $theme->css("jquery.autocomplete.css");
$buf .= $theme->css("videos.css")
. $theme->css("jquery.autocomplete.css");
$base = url::site("__ARGS__");
$csrf = access::csrf_token();
$buf .= "<script type=\"text/javascript\"> var base_url = \"$base\"; var csrf = \"$csrf\";</script>";
$buf .= $theme->script("jquery.autocomplete.js");
$buf .= $theme->script("admin_videos.js");
$buf .= $theme->script("jquery.autocomplete.js")
. $theme->script("admin_videos.js"); // rWatcher edit.
}
return $buf;
}
}
}
}

View File

@ -2,6 +2,11 @@
* Set up autocomplete on the server path list
*
*/
/**
* rWatcher Edit: This file used to be admin.js from server_add module.
* All occurences of server_add have been replaced with videos
*
*/
$("document").ready(function() {
$("#g-path").autocomplete(
base_url.replace("__ARGS__", "admin/videos/autocomplete"), {max: 256});

View File

@ -1,36 +1,41 @@
/**
* rWatcher Edit: This file used to be server_add.js from server_add module.
* All occurences of server-add have been replaced with videos
*
*/
(function($) {
$.widget("ui.gallery_server_add", {
$.widget("ui.gallery_videos", {
_init: function() {
var self = this;
$("#g-server-add-add-button", this.element).click(function(event) {
$("#g-videos-add-button", this.element).click(function(event) {
event.preventDefault();
$(".g-progress-bar", this.element).
progressbar().
progressbar("value", 0);
$("#g-server-add-progress", this.element).slideDown("fast", function() { self.start_add(); });
$("#g-videos-progress", this.element).slideDown("fast", function() { self.start_add(); });
});
$("#g-server-add-pause-button", this.element).click(function(event) {
$("#g-videos-pause-button", this.element).click(function(event) {
self.pause = true;
$("#g-server-add-pause-button", this.element).hide();
$("#g-server-add-continue-button", this.element).show();
$("#g-videos-pause-button", this.element).hide();
$("#g-videos-continue-button", this.element).show();
});
$("#g-server-add-continue-button", this.element).click(function(event) {
$("#g-videos-continue-button", this.element).click(function(event) {
self.pause = false;
$("#g-server-add-pause-button", this.element).show();
$("#g-server-add-continue-button", this.element).hide();
$("#g-videos-pause-button", this.element).show();
$("#g-videos-continue-button", this.element).hide();
self.run_add();
});
$("#g-server-add-close-button", this.element).click(function(event) {
$("#g-videos-close-button", this.element).click(function(event) {
$("#g-dialog").dialog("close");
window.location.reload();
});
$("#g-server-add-tree span.g-directory", this.element).dblclick(function(event) {
$("#g-videos-tree span.g-directory", this.element).dblclick(function(event) {
self.open_dir(event);
});
$("#g-server-add-tree span.g-file, #g-server-add-tree span.g-directory", this.element).click(function(event) {
$("#g-videos-tree span.g-file, #g-videos-tree span.g-directory", this.element).click(function(event) {
self.select_file(event);
});
$("#g-server-add-tree span.g-directory", this.element).dblclick(function(event) {
$("#g-videos-tree span.g-directory", this.element).dblclick(function(event) {
self.open_dir(event);
});
$("#g-dialog").bind("dialogclose", function(event, ui) {
@ -48,8 +53,8 @@
paths.push($(this).attr("ref"));
});
$("#g-server-add-add-button", this.element).hide();
$("#g-server-add-pause-button", this.element).show();
$("#g-videos-add-button", this.element).hide();
$("#g-videos-pause-button", this.element).show();
$.ajax({
url: START_URL,
@ -77,10 +82,10 @@
$("#g-status").html(data.status);
$(".g-progress-bar", self.element).progressbar("value", data.percent_complete);
if (data.done) {
$("#g-server-add-progress", this.element).slideUp();
$("#g-server-add-add-button", this.element).show();
$("#g-server-add-pause-button", this.element).hide();
$("#g-server-add-continue-button", this.element).hide();
$("#g-videos-progress", this.element).slideUp();
$("#g-videos-add-button", this.element).show();
$("#g-videos-pause-button", this.element).hide();
$("#g-videos-continue-button", this.element).hide();
} else {
if (!self.pause) {
setTimeout(function() { self.run_add(); }, 25);
@ -99,11 +104,11 @@
$.ajax({
url: GET_CHILDREN_URL.replace("__PATH__", path),
success: function(data, textStatus) {
$("#g-server-add-tree", self.element).html(data);
$("#g-server-add-tree span.g-directory", self.element).dblclick(function(event) {
$("#g-videos-tree", self.element).html(data);
$("#g-videos-tree span.g-directory", self.element).dblclick(function(event) {
self.open_dir(event);
});
$("#g-server-add-tree span.g-file, #g-server-add-tree span.g-directory", this.element).click(function(event) {
$("#g-videos-tree span.g-file, #g-videos-tree span.g-directory", this.element).click(function(event) {
self.select_file(event);
});
}
@ -115,10 +120,10 @@
*/
select_file: function (event) {
$(event.target).toggleClass("selected");
if ($("#g-server-add span.selected").length) {
$("#g-server-add-add-button").enable(true).removeClass("ui-state-disabled");
if ($("#g-videos span.selected").length) {
$("#g-videos-add-button").enable(true).removeClass("ui-state-disabled");
} else {
$("#g-server-add-add-button").enable(false).addClass("ui-state-disabled");
$("#g-videos-add-button").enable(false).addClass("ui-state-disabled");
}
}
});

View File

@ -0,0 +1,8 @@
/**
* rWatcher Edit: This file is one of mine.
*
*/
$("document").ready(function() {
var original_url = document.getElementById('g-videos-full-url');
$("#g-movie").replaceWith("<div id=\"g-movie\" class=\"ui-helper-clearfix\"><center><a href=\"" + original_url.href + "\">Click Here to Download Video.</a></center></div>");
});

File diff suppressed because it is too large Load Diff

View File

@ -18,5 +18,6 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher Note: This file is mine.
class Items_video_Model extends ORM {
}

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,5 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Videos_File_Model extends ORM {
// rWatcher Edit: This file used to be server_add_entry.php.
class Videos_Entry_Model_Core extends ORM {
}

View File

@ -1,3 +1,3 @@
name = "Videos"
description = "Allows authorized users to load videos directly from your web server"
version = 1
version = 4

View File

@ -1,10 +1,11 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // rWatcher Edit: This file used to be admin_server_add.html.php ?>
<div class="g-block">
<h1> <?= t("Add videos from server administration") ?> </h1>
<div class="g-block-content">
<?= $form ?>
<h2><?= t("Authorized paths") ?></h2>
<ul id="g-server-add-paths">
<ul id="g-videos-paths">
<? if (empty($paths)): ?>
<li class="g-module-status g-info"><?= t("No authorized image source paths defined yet") ?></li>
<? endif ?>

View File

@ -1,10 +1,15 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?
// rWatcher Edit: This is a combination of Gallery's movieplayer.html.php file and
// some custom edits.
$items_video = ORM::factory("items_video")
->where("item_id", "=", $item->id)
->find();
if ($items_video->loaded() && file_exists($item->resize_path() . ".flv")) {
print html::anchor(str_replace("?m=", ".flv?m=", $item->resize_url(true)), "", $attrs);
} else if ($items_video->loaded() && !(file_exists($item->resize_path() . ".flv"))) {
print "<a href=\"" . $item->file_url(true) . "\" class=\"g-movie\" id=\"g-videos-full-url\"></a>";
} else {
print html::anchor($item->file_url(true), "", $attrs);
}

View File

@ -1,28 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 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.
*/
?>
<? if (!file_exists($item->resize_path() . ".flv")) { ?>
<script type="text/javascript">
$(document).ready(function() {
$("#g-movie").replaceWith("<center><a href=\"<?= $item->file_url(true) ?>\">Click Here to Download Video.</a></center>");
});
</script>
<? } ?>

View File

@ -1,4 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // rWatcher Edit: This file used to be server_add_tree.html.php ?>
<li class="ui-icon-left">
<span class="ui-icon ui-icon-folder-open"></span>
<span class="g-directory" ref="">

View File

@ -1,13 +1,14 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // rWatcher Edit: This file used to be server_add_tree_dialog.html.php, server_add has been replaced with videos ?>
<script type="text/javascript">
var GET_CHILDREN_URL = "<?= url::site("videos/children?path=__PATH__") ?>";
var START_URL = "<?= url::site("videos/start?item_id={$item->id}&csrf=$csrf") ?>";
</script>
<div id="g-server-add">
<h1 style="display: none;"><?= t("Add Videos to '%title'", array("title" => html::purify($item->title))) ?></h1>
<div id="g-videos">
<h1 style="display: none;"><?= t("Add Photos to '%title'", array("title" => html::purify($item->title))) ?></h1>
<p id="g-description"><?= t("Videos will be added to album:") ?></p>
<p id="g-description"><?= t("Photos will be added to album:") ?></p>
<ul class="g-breadcrumbs">
<? $i = 0 ?>
<? foreach ($item->parents() as $parent): ?>
@ -17,35 +18,35 @@
<li class="g-active"> <?= html::purify($item->title) ?> </li>
</ul>
<ul id="g-server-add-tree" class="g-checkbox-tree">
<ul id="g-videos-tree" class="g-checkbox-tree">
<?= $tree ?>
</ul>
<div id="g-server-add-progress" style="display: none">
<div id="g-videos-progress" style="display: none">
<div class="g-progress-bar"></div>
<div id="g-status"></div>
</div>
<span>
<button id="g-server-add-add-button" class="ui-state-default ui-state-disabled ui-corner-all"
<button id="g-videos-add-button" class="ui-state-default ui-state-disabled ui-corner-all"
disabled="disabled">
<?= t("Add") ?>
</button>
<button id="g-server-add-pause-button" class="ui-state-default ui-corner-all" style="display:none">
<button id="g-videos-pause-button" class="ui-state-default ui-corner-all" style="display:none">
<?= t("Pause") ?>
</button>
<button id="g-server-add-continue-button" class="ui-state-default ui-corner-all" style="display:none">
<button id="g-videos-continue-button" class="ui-state-default ui-corner-all" style="display:none">
<?= t("Continue") ?>
</button>
<button id="g-server-add-close-button" class="ui-state-default ui-corner-all">
<button id="g-videos-close-button" class="ui-state-default ui-corner-all">
<?= t("Close") ?>
</button>
</span>
<script type="text/javascript">
$("#g-server-add").ready(function() {
$("#g-server-add").gallery_server_add();
$("#g-videos").ready(function() {
$("#g-videos").gallery_videos();
});
</script>

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,10 +17,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher EDIT: This file used to be admin_server_add.php.
// All occurences of server_add have been replaced with videos.
class Admin_Videos_Controller extends Admin_Controller {
public function index() {
$view = new Admin_View("admin.html");
$view->page_title = t("Add videos from server");
$view->page_title = t("Add from server");
$view->content = new View("admin_videos.html");
$view->content->form = $this->_get_admin_form();
$paths = unserialize(module::get_var("videos", "authorized_paths", "a:0:{}"));

View File

@ -0,0 +1,144 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 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.
*/
/**
* Proxy access to files in var/albums and var/resizes, making sure that the session user has
* access to view these files.
*
* Security Philosophy: we do not use the information provided to find if the file exists on
* disk. We use this information only to locate the correct item in the database and then we
* *only* use information from the database to find and proxy the correct file. This way all user
* input is sanitized against the database before we perform any file I/O.
*/
class File_Proxy_Controller extends Controller {
const ALLOW_PRIVATE_GALLERY = true;
public function __call($function, $args) {
// request_uri: gallery3/var/albums/foo/bar.jpg?m=1234
$request_uri = rawurldecode(Input::instance()->server("REQUEST_URI"));
// get rid of query parameters
// request_uri: gallery3/var/albums/foo/bar.jpg
$request_uri = preg_replace("/\?.*/", "", $request_uri);
// var_uri: gallery3/var/
$var_uri = url::file("var/");
// Make sure that the request is for a file inside var
$offset = strpos(rawurldecode($request_uri), $var_uri);
if ($offset !== 0) {
throw new Kohana_404_Exception();
}
// file_uri: albums/foo/bar.jpg
$file_uri = substr($request_uri, strlen($var_uri));
// type: albums
// path: foo/bar.jpg
list ($type, $path) = explode("/", $file_uri, 2);
if ($type != "resizes" && $type != "albums" && $type != "thumbs") {
throw new Kohana_404_Exception();
}
// If the last element is .album.jpg, pop that off since it's not a real item
$path = preg_replace("|/.album.jpg$|", "", $path);
$item = item::find_by_path($path);
if (!$item->loaded()) {
// We didn't turn it up. If we're looking for a .jpg then it's it's possible that we're
// requesting the thumbnail for a movie. In that case, the .flv, .mp4 or .m4v file would
// have been converted to a .jpg. So try some alternate types:
if (preg_match('/.jpg$/', $path)) {
// rWatcher Mod: look for videos with file extensions supported by the videos module in addition to flv mp4 and m4v
// Original Line: foreach (array("flv", "mp4", "m4v") as $ext) {
foreach (array_merge(array("flv", "mp4", "m4v"), unserialize(module::get_var("videos", "allowed_extensions"))) as $ext) {
$movie_path = preg_replace('/.jpg$/', ".$ext", $path);
$item = item::find_by_path($movie_path);
if ($item->loaded()) {
break;
}
}
}
// rWatcher Mod:
// If we're looking for a .flv then it's it's possible that we're requesting a flash resize
// for a movie.
if (strtolower(substr($path, strlen($path)-4)) == ".flv") {
$movie_path = str_ireplace(".flv", "", $path);
$item = ORM::factory("item")->where("relative_path_cache", "=", $movie_path)->find();
}
// END rWatcher Mod
}
if (!$item->loaded()) {
throw new Kohana_404_Exception();
}
// Make sure we have access to the item
if (!access::can("view", $item)) {
throw new Kohana_404_Exception();
}
// Make sure we have view_full access to the original
if ($type == "albums" && !access::can("view_full", $item)) {
throw new Kohana_404_Exception();
}
// Don't try to load a directory
if ($type == "albums" && $item->is_album()) {
throw new Kohana_404_Exception();
}
if ($type == "albums") {
$file = $item->file_path();
} else if ($type == "resizes") {
$file = $item->resize_path();
// rWatcher MOD
// If the resize is for a movie, assume it needs a .flv extension.
if ($item->is_movie()) {
$file = $file . ".flv";
}
// End rWatcher MOD
} else {
$file = $item->thumb_path();
}
if (!file_exists($file)) {
throw new Kohana_404_Exception();
}
header("Content-Length: " . filesize($file));
header("Pragma:");
// Check that the content hasn't expired or it wasn't changed since cached
expires::check(2592000, $item->updated);
// We don't need to save the session for this request
Session::instance()->abort_save();
expires::set(2592000, $item->updated); // 30 days
// Dump out the image. If the item is a movie, then its thumbnail will be a JPG.
if ($item->is_movie() && $type != "albums") {
header("Content-Type: image/jpeg");
} else {
header("Content-Type: $item->mime_type");
}
Kohana::close_buffers(false);
readfile($file);
}
}

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,6 +17,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher Edit: This file used to be server_add.php.
// All occurences of server_add have been replaced with videos.
// Additional editing has also been done in three places to expand accepted file
// extensions and to create resizes and an extra db entry for items_videos.
class Videos_Controller extends Admin_Controller {
public function browse($id) {
$paths = unserialize(module::get_var("videos", "authorized_paths"));
@ -24,6 +30,12 @@ class Videos_Controller extends Admin_Controller {
$files[] = $path;
}
// Clean leftover task rows. There really should be support for this in the task framework
db::build()
->where("task_id", "NOT IN", db::build()->select("id")->from("tasks"))
->delete("videos_entries")
->execute();
$item = ORM::factory("item", $id);
$view = new View("videos_tree_dialog.html");
$view->item = $item;
@ -55,6 +67,7 @@ class Videos_Controller extends Admin_Controller {
}
if (!is_dir($file)) {
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
// rWatcher Edit
//if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4", "m4v"))) {
if (!in_array($ext, unserialize(module::get_var("videos", "allowed_extensions")))) {
continue;
@ -74,23 +87,28 @@ class Videos_Controller extends Admin_Controller {
}
/**
* Begin the task of adding files.
* Begin the task of adding photos.
*/
public function start() {
access::verify_csrf();
$item = ORM::factory("item", Input::instance()->get("item_id"));
foreach (Input::instance()->post("paths") as $path) {
if (videos::is_valid_path($path)) {
$paths[] = array($path, null);
}
}
$task_def = Task_Definition::factory()
->callback("Videos_Controller::add")
->description(t("Add videos from the local server"))
->description(t("Add photos or movies from the local server"))
->name(t("Add from server"));
$task = task::create($task_def, array("item_id" => $item->id, "queue" => $paths));
$task = task::create($task_def, array("item_id" => $item->id));
foreach (Input::instance()->post("paths") as $path) {
if (videos::is_valid_path($path)) {
$entry = ORM::factory("videos_entry");
$entry->path = $path;
$entry->is_directory = intval(is_dir($path));
$entry->parent_id = null;
$entry->task_id = $task->id;
$entry->save();
}
}
json::reply(
array("result" => "started",
@ -99,7 +117,7 @@ class Videos_Controller extends Admin_Controller {
}
/**
* Run the task of adding files
* Run the task of adding photos
*/
function run($task_id) {
access::verify_csrf();
@ -119,7 +137,7 @@ class Videos_Controller extends Admin_Controller {
/**
* This is the task code that adds photos and albums. It first examines all the target files
* and creates a set of Server_Add_File_Models, then runs through the list of models and adds
* and creates a set of Server_Add_Entry_Models, then runs through the list of models and adds
* them one at a time.
*/
static function add($task) {
@ -129,6 +147,7 @@ class Videos_Controller extends Admin_Controller {
switch ($mode) {
case "init":
$task->set("mode", "build-file-list");
$task->set("dirs_scanned", 0);
$task->percent_complete = 0;
$task->status = t("Starting up");
batch::start();
@ -137,59 +156,64 @@ class Videos_Controller extends Admin_Controller {
case "build-file-list": // 0% to 10%
// We can't fit an arbitrary number of paths in a task, so store them in a separate table.
// Don't use an iterator here because we can't get enough control over it when we're dealing
// with a deep hierarchy and we don't want to go over our time quota. The queue is in the
// form [path, parent_id] where the parent_id refers to another Server_Add_File_Model. We
// have this extra level of abstraction because we don't know its Item_Model id yet.
$queue = $task->get("queue");
// with a deep hierarchy and we don't want to go over our time quota.
$paths = unserialize(module::get_var("videos", "authorized_paths"));
$dirs_scanned = $task->get("dirs_scanned");
while (microtime(true) - $start < 0.5) {
// Process every directory that doesn't yet have a parent id, these are the
// paths that we're importing.
$entry = ORM::factory("videos_entry")
->where("task_id", "=", $task->id)
->where("is_directory", "=", 1)
->where("checked", "=", 0)
->order_by("id", "ASC")
->find();
while ($queue && microtime(true) - $start < 0.5) {
list($file, $parent_entry_id) = array_shift($queue);
// Ignore the staging directories as directories to be imported.
if (empty($paths[$file])) {
$entry = ORM::factory("videos_file");
$entry->task_id = $task->id;
$entry->file = $file;
$entry->parent_id = $parent_entry_id;
$entry->save();
$entry_id = $entry->id;
} else {
$entry_id = null;
}
$file = preg_quote($file);
foreach (glob("$file/*") as $child) {
if (is_dir($child)) {
$queue[] = array($child, $entry_id);
} else {
$ext = strtolower(pathinfo($child, PATHINFO_EXTENSION));
//if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4", "m4v")) &&
if (in_array($ext, unserialize(module::get_var("videos", "allowed_extensions"))) &&
filesize($child) > 0) {
$child_entry = ORM::factory("videos_file");
$child_entry->task_id = $task->id;
$child_entry->file = $child;
$child_entry->parent_id = $entry_id;
$child_entry->save();
}
if ($entry->loaded()) {
$child_paths = glob(preg_quote($entry->path) . "/*");
if (!$child_paths) {
$child_paths = glob("{$entry->path}/*");
}
foreach ($child_paths as $child_path) {
if (!is_dir($child_path)) {
$ext = strtolower(pathinfo($child_path, PATHINFO_EXTENSION));
// rWatcher Edit.
//if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4", "m4v")) ||
// !filesize($child_path)) {
if (!in_array($ext, unserialize(module::get_var("videos", "allowed_extensions"))) ||
!filesize($child_path)) {
// Not importable, skip it.
continue;
}
}
$child_entry = ORM::factory("videos_entry");
$child_entry->task_id = $task->id;
$child_entry->path = $child_path;
$child_entry->parent_id = $entry->id; // null if the parent was a staging dir
$child_entry->is_directory = is_dir($child_path);
$child_entry->save();
}
// We've processed this entry, mark it as done.
$entry->checked = 1;
$entry->save();
$dirs_scanned++;
}
}
// We have no idea how long this can take because we have no idea how deep the tree
// hierarchy rabbit hole goes. Leave ourselves room here for 100 iterations and don't go
// over 10% in percent_complete.
$task->set("queue", $queue);
$task->set("dirs_scanned", $dirs_scanned);
$task->percent_complete = min($task->percent_complete + 0.1, 10);
$task->status = t2(
"Found one file", "Found %count files",
ORM::factory("videos_file")->where("task_id", "=", $task->id)->count_all());
$task->status = t2("Scanned one directory", "Scanned %count directories", $dirs_scanned);
if (!$queue) {
if (!$entry->loaded()) {
$task->set("mode", "add-files");
$task->set(
"total_files",
ORM::factory("videos_file")->where("task_id", "=", $task->id)->count_all());
ORM::factory("videos_entry")->where("task_id", "=", $task->id)->count_all());
$task->percent_complete = 10;
}
break;
@ -201,7 +225,7 @@ class Videos_Controller extends Admin_Controller {
// Ordering by id ensures that we add them in the order that we created the entries, which
// will create albums first. Ignore entries which already have an Item_Model attached,
// they're done.
$entries = ORM::factory("videos_file")
$entries = ORM::factory("videos_entry")
->where("task_id", "=", $task->id)
->where("item_id", "IS", null)
->order_by("id", "ASC")
@ -220,43 +244,59 @@ class Videos_Controller extends Admin_Controller {
// Look up the parent item for this entry. By now it should exist, but if none was
// specified, then this belongs as a child of the current item.
$parent_entry = ORM::factory("videos_file", $entry->parent_id);
$parent_entry = ORM::factory("videos_entry", $entry->parent_id);
if (!$parent_entry->loaded()) {
$parent = ORM::factory("item", $task->get("item_id"));
} else {
$parent = ORM::factory("item", $parent_entry->item_id);
}
$name = basename($entry->file);
$name = basename($entry->path);
$title = item::convert_filename_to_title($name);
if (is_dir($entry->file)) {
if ($entry->is_directory) {
$album = ORM::factory("item");
$album->type = "album";
$album->parent_id = $parent->id;
$album->name = $name;
$album->title = $title;
$album->owner_id = $owner_id;
$album->sort_order = $parent->sort_order;
$album->sort_column = $parent->sort_column;
$album->save();
$entry->item_id = $album->id;
} else {
try {
$extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
if (in_array($extension, unserialize(module::get_var("videos", "allowed_extensions")))) {
if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) {
$photo = ORM::factory("item");
$photo->type = "photo";
$photo->parent_id = $parent->id;
$photo->set_data_file($entry->path);
$photo->name = $name;
$photo->title = $title;
$photo->owner_id = $owner_id;
$photo->save();
$entry->item_id = $photo->id;
// rWatcher EDIT
//} else if (in_array($extension, array("flv", "mp4", "m4v"))) {
} else if (in_array($extension, unserialize(module::get_var("videos", "allowed_extensions")))) {
$movie = ORM::factory("item");
$movie->type = "movie";
$movie->parent_id = $parent->id;
$movie->set_data_file($entry->file);
$movie->set_data_file($entry->path);
$movie->name = $name;
$movie->title = $title;
$movie->owner_id = $owner_id;
$movie->save();
$entry->item_id = $movie->id;
// rWatcher EDIT: Add record to items_video db.
$items_video = ORM::factory("items_video");
$items_video->item_id = $movie->id;
$items_video->save();
if (file_exists($entry->file . ".flv")) {
copy($entry->file . ".flv", $movie->resize_path() . ".flv");
list ($vid_width, $vid_height, $mime_type) = movie::get_file_metadata($entry->file . ".flv");
// rWatcher EDIT: Scan for flv resizes and copy to resize directory.
if (file_exists($entry->path . ".flv")) {
copy($entry->path . ".flv", $movie->resize_path() . ".flv");
list ($vid_width, $vid_height, $mime_type) = movie::get_file_metadata($entry->path . ".flv");
$movie->height = $vid_height;
$movie->width = $vid_width;
$movie->save();
@ -266,12 +306,12 @@ class Videos_Controller extends Admin_Controller {
// process. But just in, case.. set this to a non-null value so that we skip this
// entry.
$entry->item_id = 0;
$task->log("Skipping unknown file type: $entry->file");
$task->log("Skipping unknown file type: {$entry->path}");
}
} catch (Exception $e) {
// This can happen if a photo file is invalid, like a BMP masquerading as a .jpg
$entry->item_id = 0;
$task->log("Skipping invalid file: $entry->file");
$task->log("Skipping invalid file: {$entry->file}");
}
}
@ -290,12 +330,11 @@ class Videos_Controller extends Admin_Controller {
$task->done = true;
$task->state = "success";
$task->percent_complete = 100;
db::build()
->delete("videos_files")
ORM::factory("videos_entry")
->where("task_id", "=", $task->id)
->execute();
message::info(t2("Successfully added one file",
"Successfully added %count files",
->delete_all();
message::info(t2("Successfully added one photo / album",
"Successfully added %count photos / albums",
$task->get("completed_files")));
}
}

View File

@ -1,23 +1,23 @@
#g-server-add button {
#g-videos button {
margin-bottom: .5em;
}
#g-server-add-tree {
#g-videos-tree {
cursor: pointer;
padding-left: 4px;
width: 95%;
}
#g-server-add-tree li {
#g-videos-tree li {
padding: 0;
float: none;
}
#g-server-add-tree span.selected {
#g-videos-tree span.selected {
background: #ddd;
}
#g-server-add-tree {
#g-videos-tree {
border: 1px solid #ccc;
height: 20em;
overflow: auto;
@ -25,14 +25,14 @@
padding: .5em;
}
#g-server-add ul ul li {
#g-videos ul ul li {
padding-left: 1.2em;
}
#g-server-add-paths li .ui-icon {
#g-videos-paths li .ui-icon {
margin-top: .4em;
}
#g-server-add-admin-form .textbox {
#g-videos-admin-form .textbox {
width: 400px;
}

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,6 +17,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher edit: This file used to be server_add.php.
// All occurences of server_add have been replaced with videos.
class videos_Core {
static function check_config($paths=null) {
if ($paths === null) {

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,6 +17,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher Edit: This file used to be server_add_event.php.
// All occurences of server_add have been replaced with videos.
// Additionally, several new functions have been added.
class videos_event_Core {
static function admin_menu($menu, $theme) {
$menu->get("settings_menu")
@ -34,7 +38,7 @@ class videos_event_Core {
is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path())) {
$menu->get("add_menu")
->append(Menu::factory("dialog")
->id("videos")
->id("Videos")
->label(t("Add videos"))
->url(url::site("videos/browse/$item->id")));
}

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,36 +17,60 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher Edit: This file was server_add_installer.
// All occurences of server_add have been replaced with videos.
// The installer has been edited to create an additional table and module variable.
// The upgrader has been edited to skip everything before version 4, to keep version numbers in sync with server_add.
class videos_installer {
static function install() {
$db = Database::instance();
$db->query("CREATE TABLE {videos_files} (
$db->query("CREATE TABLE {videos_entries} (
`id` int(9) NOT NULL auto_increment,
`file` varchar(255) NOT NULL,
`checked` boolean default 0,
`is_directory` boolean default 0,
`item_id` int(9),
`parent_id` int(9),
`path` varchar(255) NOT NULL,
`task_id` int(9) NOT NULL,
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
// rWatcher Edit: My Table.
$db->query("CREATE TABLE {items_videos} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9) NOT NULL,
PRIMARY KEY (`id`),
KEY (`item_id`, `id`))
DEFAULT CHARSET=utf8;");
// rWatcher Edit: My Variable.
module::set_var("videos", "allowed_extensions", serialize(array("avi", "mpg", "mpeg", "mov", "wmv", "asf", "mts")));
module::set_version("videos", 1);
module::set_version("videos", 4);
videos::check_config();
}
static function upgrade($version) {
$db = Database::instance();
if ($version < 4) {
$db->query("DROP TABLE {videos_files}");
$db->query("CREATE TABLE {videos_entries} (
`id` int(9) NOT NULL auto_increment,
`checked` boolean default 0,
`is_directory` boolean default 0,
`item_id` int(9),
`parent_id` int(9),
`path` varchar(255) NOT NULL,
`task_id` int(9) NOT NULL,
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
module::set_version("videos", $version = 4);
}
}
static function deactivate() {
site_status::clear("videos_configuration");
}
static function uninstall() {
$db = Database::instance();
$db->query("DROP TABLE IF EXISTS {videos_files};");
$db->query("DROP TABLE IF EXISTS {items_videos};");
module::delete("videos");
}
}

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,6 +17,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher Edit: This file used to be server_add_theme.php.
// All occurences of server_add have been replaced with videos.
// Additionally, the head function has been reworked to provide a
// download link for unplayable videos and references to admin.js are now admin_videos.js.
class videos_theme_Core {
static function head($theme) {
$buf = "";
@ -30,27 +36,26 @@ class videos_theme_Core {
$items_video = ORM::factory("items_video")
->where("item_id", "=", $item->id)
->find();
if ($items_video->loaded()) {
$view = new View("videos_display_js.html");
//$view->embed_code = addslashes($embedded_video->embed_code);
return $buf . $view;
if (($items_video->loaded()) && (!file_exists($item->resize_path() . ".flv"))) {
$buf .= $theme->script("videos_download.js");
}
}
return $buf;
}
static function admin_head($theme) {
$buf = "";
if (strpos(Router::$current_uri, "admin/videos") !== false) {
$buf .= $theme->css("videos.css");
$buf .= $theme->css("jquery.autocomplete.css");
$buf .= $theme->css("videos.css")
. $theme->css("jquery.autocomplete.css");
$base = url::site("__ARGS__");
$csrf = access::csrf_token();
$buf .= "<script type=\"text/javascript\"> var base_url = \"$base\"; var csrf = \"$csrf\";</script>";
$buf .= $theme->script("jquery.autocomplete.js");
$buf .= $theme->script("admin_videos.js");
$buf .= $theme->script("jquery.autocomplete.js")
. $theme->script("admin_videos.js"); // rWatcher edit.
}
return $buf;
}
}
}

View File

@ -2,6 +2,11 @@
* Set up autocomplete on the server path list
*
*/
/**
* rWatcher Edit: This file used to be admin.js from server_add module.
* All occurences of server_add have been replaced with videos
*
*/
$("document").ready(function() {
$("#g-path").autocomplete(
base_url.replace("__ARGS__", "admin/videos/autocomplete"), {max: 256});

View File

@ -1,36 +1,41 @@
/**
* rWatcher Edit: This file used to be server_add.js from server_add module.
* All occurences of server-add have been replaced with videos
*
*/
(function($) {
$.widget("ui.gallery_server_add", {
$.widget("ui.gallery_videos", {
_init: function() {
var self = this;
$("#g-server-add-add-button", this.element).click(function(event) {
$("#g-videos-add-button", this.element).click(function(event) {
event.preventDefault();
$(".g-progress-bar", this.element).
progressbar().
progressbar("value", 0);
$("#g-server-add-progress", this.element).slideDown("fast", function() { self.start_add(); });
$("#g-videos-progress", this.element).slideDown("fast", function() { self.start_add(); });
});
$("#g-server-add-pause-button", this.element).click(function(event) {
$("#g-videos-pause-button", this.element).click(function(event) {
self.pause = true;
$("#g-server-add-pause-button", this.element).hide();
$("#g-server-add-continue-button", this.element).show();
$("#g-videos-pause-button", this.element).hide();
$("#g-videos-continue-button", this.element).show();
});
$("#g-server-add-continue-button", this.element).click(function(event) {
$("#g-videos-continue-button", this.element).click(function(event) {
self.pause = false;
$("#g-server-add-pause-button", this.element).show();
$("#g-server-add-continue-button", this.element).hide();
$("#g-videos-pause-button", this.element).show();
$("#g-videos-continue-button", this.element).hide();
self.run_add();
});
$("#g-server-add-close-button", this.element).click(function(event) {
$("#g-videos-close-button", this.element).click(function(event) {
$("#g-dialog").dialog("close");
window.location.reload();
});
$("#g-server-add-tree span.g-directory", this.element).dblclick(function(event) {
$("#g-videos-tree span.g-directory", this.element).dblclick(function(event) {
self.open_dir(event);
});
$("#g-server-add-tree span.g-file, #g-server-add-tree span.g-directory", this.element).click(function(event) {
$("#g-videos-tree span.g-file, #g-videos-tree span.g-directory", this.element).click(function(event) {
self.select_file(event);
});
$("#g-server-add-tree span.g-directory", this.element).dblclick(function(event) {
$("#g-videos-tree span.g-directory", this.element).dblclick(function(event) {
self.open_dir(event);
});
$("#g-dialog").bind("dialogclose", function(event, ui) {
@ -48,8 +53,8 @@
paths.push($(this).attr("ref"));
});
$("#g-server-add-add-button", this.element).hide();
$("#g-server-add-pause-button", this.element).show();
$("#g-videos-add-button", this.element).hide();
$("#g-videos-pause-button", this.element).show();
$.ajax({
url: START_URL,
@ -77,10 +82,10 @@
$("#g-status").html(data.status);
$(".g-progress-bar", self.element).progressbar("value", data.percent_complete);
if (data.done) {
$("#g-server-add-progress", this.element).slideUp();
$("#g-server-add-add-button", this.element).show();
$("#g-server-add-pause-button", this.element).hide();
$("#g-server-add-continue-button", this.element).hide();
$("#g-videos-progress", this.element).slideUp();
$("#g-videos-add-button", this.element).show();
$("#g-videos-pause-button", this.element).hide();
$("#g-videos-continue-button", this.element).hide();
} else {
if (!self.pause) {
setTimeout(function() { self.run_add(); }, 25);
@ -99,11 +104,11 @@
$.ajax({
url: GET_CHILDREN_URL.replace("__PATH__", path),
success: function(data, textStatus) {
$("#g-server-add-tree", self.element).html(data);
$("#g-server-add-tree span.g-directory", self.element).dblclick(function(event) {
$("#g-videos-tree", self.element).html(data);
$("#g-videos-tree span.g-directory", self.element).dblclick(function(event) {
self.open_dir(event);
});
$("#g-server-add-tree span.g-file, #g-server-add-tree span.g-directory", this.element).click(function(event) {
$("#g-videos-tree span.g-file, #g-videos-tree span.g-directory", this.element).click(function(event) {
self.select_file(event);
});
}
@ -115,10 +120,10 @@
*/
select_file: function (event) {
$(event.target).toggleClass("selected");
if ($("#g-server-add span.selected").length) {
$("#g-server-add-add-button").enable(true).removeClass("ui-state-disabled");
if ($("#g-videos span.selected").length) {
$("#g-videos-add-button").enable(true).removeClass("ui-state-disabled");
} else {
$("#g-server-add-add-button").enable(false).addClass("ui-state-disabled");
$("#g-videos-add-button").enable(false).addClass("ui-state-disabled");
}
}
});

View File

@ -0,0 +1,8 @@
/**
* rWatcher Edit: This file is one of mine.
*
*/
$("document").ready(function() {
var original_url = document.getElementById('g-videos-full-url');
$("#g-movie").replaceWith("<div id=\"g-movie\" class=\"ui-helper-clearfix\"><center><a href=\"" + original_url.href + "\">Click Here to Download Video.</a></center></div>");
});

File diff suppressed because it is too large Load Diff

View File

@ -18,5 +18,6 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
// rWatcher Note: This file is mine.
class Items_video_Model extends ORM {
}

View File

@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
* 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
@ -17,5 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Videos_File_Model extends ORM {
// rWatcher Edit: This file used to be server_add_entry.php.
class Videos_Entry_Model_Core extends ORM {
}

View File

@ -1,3 +1,3 @@
name = "Videos"
description = "Allows authorized users to load videos directly from your web server"
version = 1
version = 4

View File

@ -1,10 +1,11 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // rWatcher Edit: This file used to be admin_server_add.html.php ?>
<div class="g-block">
<h1> <?= t("Add videos from server administration") ?> </h1>
<div class="g-block-content">
<?= $form ?>
<h2><?= t("Authorized paths") ?></h2>
<ul id="g-server-add-paths">
<ul id="g-videos-paths">
<? if (empty($paths)): ?>
<li class="g-module-status g-info"><?= t("No authorized image source paths defined yet") ?></li>
<? endif ?>

View File

@ -1,10 +1,15 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?
// rWatcher Edit: This is a combination of Gallery's movieplayer.html.php file and
// some custom edits.
$items_video = ORM::factory("items_video")
->where("item_id", "=", $item->id)
->find();
if ($items_video->loaded() && file_exists($item->resize_path() . ".flv")) {
print html::anchor(str_replace("?m=", ".flv?m=", $item->resize_url(true)), "", $attrs);
} else if ($items_video->loaded() && !(file_exists($item->resize_path() . ".flv"))) {
print "<a href=\"" . $item->file_url(true) . "\" class=\"g-movie\" id=\"g-videos-full-url\"></a>";
} else {
print html::anchor($item->file_url(true), "", $attrs);
}

View File

@ -1,28 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 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.
*/
?>
<? if (!file_exists($item->resize_path() . ".flv")) { ?>
<script type="text/javascript">
$(document).ready(function() {
$("#g-movie").replaceWith("<center><a href=\"<?= $item->file_url(true) ?>\">Click Here to Download Video.</a></center>");
});
</script>
<? } ?>

View File

@ -1,4 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // rWatcher Edit: This file used to be server_add_tree.html.php ?>
<li class="ui-icon-left">
<span class="ui-icon ui-icon-folder-open"></span>
<span class="g-directory" ref="">

View File

@ -1,13 +1,14 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // rWatcher Edit: This file used to be server_add_tree_dialog.html.php, server_add has been replaced with videos ?>
<script type="text/javascript">
var GET_CHILDREN_URL = "<?= url::site("videos/children?path=__PATH__") ?>";
var START_URL = "<?= url::site("videos/start?item_id={$item->id}&csrf=$csrf") ?>";
</script>
<div id="g-server-add">
<h1 style="display: none;"><?= t("Add Videos to '%title'", array("title" => html::purify($item->title))) ?></h1>
<div id="g-videos">
<h1 style="display: none;"><?= t("Add Photos to '%title'", array("title" => html::purify($item->title))) ?></h1>
<p id="g-description"><?= t("Videos will be added to album:") ?></p>
<p id="g-description"><?= t("Photos will be added to album:") ?></p>
<ul class="g-breadcrumbs">
<? $i = 0 ?>
<? foreach ($item->parents() as $parent): ?>
@ -17,35 +18,35 @@
<li class="g-active"> <?= html::purify($item->title) ?> </li>
</ul>
<ul id="g-server-add-tree" class="g-checkbox-tree">
<ul id="g-videos-tree" class="g-checkbox-tree">
<?= $tree ?>
</ul>
<div id="g-server-add-progress" style="display: none">
<div id="g-videos-progress" style="display: none">
<div class="g-progress-bar"></div>
<div id="g-status"></div>
</div>
<span>
<button id="g-server-add-add-button" class="ui-state-default ui-state-disabled ui-corner-all"
<button id="g-videos-add-button" class="ui-state-default ui-state-disabled ui-corner-all"
disabled="disabled">
<?= t("Add") ?>
</button>
<button id="g-server-add-pause-button" class="ui-state-default ui-corner-all" style="display:none">
<button id="g-videos-pause-button" class="ui-state-default ui-corner-all" style="display:none">
<?= t("Pause") ?>
</button>
<button id="g-server-add-continue-button" class="ui-state-default ui-corner-all" style="display:none">
<button id="g-videos-continue-button" class="ui-state-default ui-corner-all" style="display:none">
<?= t("Continue") ?>
</button>
<button id="g-server-add-close-button" class="ui-state-default ui-corner-all">
<button id="g-videos-close-button" class="ui-state-default ui-corner-all">
<?= t("Close") ?>
</button>
</span>
<script type="text/javascript">
$("#g-server-add").ready(function() {
$("#g-server-add").gallery_server_add();
$("#g-videos").ready(function() {
$("#g-videos").gallery_videos();
});
</script>