From eecb0a6ad5e3c1bf45d0b01c5f12a4aa5532a8dc Mon Sep 17 00:00:00 2001 From: brentil Date: Wed, 24 Nov 2010 11:50:11 +0800 Subject: [PATCH 01/23] ModuleUpdates v4.0 beta, uses installed version information to dynamically determine git location. gallery::VERSION info is wrong though --- .../controllers/admin_moduleupdates.php | 13 +++++++------ .../moduleupdates/helpers/moduleupdates_event.php | 2 +- .../helpers/moduleupdates_installer.php | 6 +++--- 3.0/modules/moduleupdates/module.info | 2 +- .../views/admin_moduleupdates.html.php | 6 +++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/3.0/modules/moduleupdates/controllers/admin_moduleupdates.php b/3.0/modules/moduleupdates/controllers/admin_moduleupdates.php index 921cf535..df6ca12d 100755 --- a/3.0/modules/moduleupdates/controllers/admin_moduleupdates.php +++ b/3.0/modules/moduleupdates/controllers/admin_moduleupdates.php @@ -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 . '
'; @@ -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 = 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/". 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/". gallery::VERSION ."/modules/".$module_name."/module.info", "r"); if ($file != null) { - $server = '(G3CC)'; + $server = '(GCC)'; } } catch (Exception $e) { diff --git a/3.0/modules/moduleupdates/helpers/moduleupdates_event.php b/3.0/modules/moduleupdates/helpers/moduleupdates_event.php index dd6efc9c..8dbed46c 100644 --- a/3.0/modules/moduleupdates/helpers/moduleupdates_event.php +++ b/3.0/modules/moduleupdates/helpers/moduleupdates_event.php @@ -27,4 +27,4 @@ class moduleupdates_event_Core { ->label(t("Module Updates")) ->url(url::site("admin/moduleupdates"))); } -} \ No newline at end of file +} diff --git a/3.0/modules/moduleupdates/helpers/moduleupdates_installer.php b/3.0/modules/moduleupdates/helpers/moduleupdates_installer.php index dd0dddb8..39d1dcc0 100644 --- a/3.0/modules/moduleupdates/helpers/moduleupdates_installer.php +++ b/3.0/modules/moduleupdates/helpers/moduleupdates_installer.php @@ -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"); } -} +} \ No newline at end of file diff --git a/3.0/modules/moduleupdates/module.info b/3.0/modules/moduleupdates/module.info index cf43770b..722abecc 100755 --- a/3.0/modules/moduleupdates/module.info +++ b/3.0/modules/moduleupdates/module.info @@ -1,3 +1,3 @@ name = "Module Updates" description = "Compares your installed module version against the ones stored in the GitHub." -version = 3 +version = 4 \ No newline at end of file diff --git a/3.0/modules/moduleupdates/views/admin_moduleupdates.html.php b/3.0/modules/moduleupdates/views/admin_moduleupdates.html.php index 3fdc06a7..3d7d5453 100644 --- a/3.0/modules/moduleupdates/views/admin_moduleupdates.html.php +++ b/3.0/modules/moduleupdates/views/admin_moduleupdates.html.php @@ -2,7 +2,7 @@
-

+

@@ -25,7 +25,7 @@
    -
  • +
@@ -45,4 +45,4 @@
-
\ No newline at end of file + From 14fe5d5d3dda9f0aac541b72142f5aa60f5014a6 Mon Sep 17 00:00:00 2001 From: brentil Date: Wed, 24 Nov 2010 12:57:14 +0800 Subject: [PATCH 02/23] MU v4.0 final. Added a hack for now to convert gallery::VERSION into the information needed. --- .../moduleupdates/controllers/admin_moduleupdates.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/3.0/modules/moduleupdates/controllers/admin_moduleupdates.php b/3.0/modules/moduleupdates/controllers/admin_moduleupdates.php index df6ca12d..b1274111 100755 --- a/3.0/modules/moduleupdates/controllers/admin_moduleupdates.php +++ b/3.0/modules/moduleupdates/controllers/admin_moduleupdates.php @@ -167,7 +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 = gallery::VERSION; + $view->content->Gallery_Version = substr_replace(gallery::VERSION,"",strpos(gallery::VERSION," ")); print $view; @@ -198,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/". gallery::VERSION ."/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)'; } @@ -225,7 +225,7 @@ 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/". gallery::VERSION ."/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 = '(GCC)'; } From f3d96447454c9347f6650a87289f99bd2e622e86 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Mon, 15 Nov 2010 02:23:28 +0800 Subject: [PATCH 03/23] Sync with wind --- 3.0/themes/sobriety/js/ui.init.js | 9 +++++++++ 3.0/themes/sobriety/theme.info | 4 ++-- 3.0/themes/sobriety/views/album.html.php | 4 +++- 3.0/themes/sobriety/views/page.html.php | 24 ++++++++++++++---------- 3.0/themes/sobriety/views/photo.html.php | 15 ++++++++++++++- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/3.0/themes/sobriety/js/ui.init.js b/3.0/themes/sobriety/js/ui.init.js index 4393a04a..eeaa1b6d 100644 --- a/3.0/themes/sobriety/js/ui.init.js +++ b/3.0/themes/sobriety/js/ui.init.js @@ -90,9 +90,18 @@ $(document).ready(function() { $(this).css("top", 0).css("left", 0); // Remove the placeholder and hover class from the item $(this).removeClass("g-hover-item"); + $(this).gallery_valign(); $("#g-place-holder").remove(); } ); + + // Realign any thumbnails that change so that when we rotate a thumb it stays centered. + $(".g-item").bind("gallery.change", function() { + $(".g-item").each(function() { + $(this).height($(this).find("img").height() + 2); + }); + $(".g-item").equal_heights().gallery_valign(); + }); }*/ // Photo/Item item view diff --git a/3.0/themes/sobriety/theme.info b/3.0/themes/sobriety/theme.info index 545a0815..bcb836a6 100644 --- a/3.0/themes/sobriety/theme.info +++ b/3.0/themes/sobriety/theme.info @@ -4,5 +4,5 @@ version = 1 author = "Romain LE DISEZ" site = 1 admin = 0 -;wind commit = 3b05db2685d92ca538d7993c960b06ea32f3a8df -;wind date = Wed Jun 23 11:16:56 2010 -0700 +;wind commit = 3a9bdebafda1807bb2294c041e655f6464841bf0 +;wind date = Tue Sep 21 21:38:32 2010 -0700 diff --git a/3.0/themes/sobriety/views/album.html.php b/3.0/themes/sobriety/views/album.html.php index b9072e2b..1a56af67 100644 --- a/3.0/themes/sobriety/views/album.html.php +++ b/3.0/themes/sobriety/views/album.html.php @@ -16,7 +16,9 @@
  • thumb_top($child) ?> + has_thumb()): ?> thumb_img(array("class" => "g-thumbnail")) ?> + thumb_bottom($child) ?> context_menu($child, "#g-item-id-{$child->id} .g-thumbnail") ?> @@ -29,7 +31,7 @@ admin || access::can("add", $item)): ?> - id") ?> + id") ?>
  • Add some.", array("attrs" => html::mark_clean("href=\"$addurl\" class=\"g-dialog-link\""))) ?>
  • diff --git a/3.0/themes/sobriety/views/page.html.php b/3.0/themes/sobriety/views/page.html.php index cf10b85e..a4610460 100644 --- a/3.0/themes/sobriety/views/page.html.php +++ b/3.0/themes/sobriety/views/page.html.php @@ -23,13 +23,12 @@ - " type="image/x-icon" /> + " type="image/x-icon" /> css("_DISABLED_yui/reset-fonts-grids.css") ?> css("_DISABLED_superfish/css/superfish.css") ?> css("_DISABLED_themeroller/ui.base.css") ?> - css("_DISABLED_gallery.common.css") ?> css("screen.css") ?> - @@ -90,17 +89,22 @@ > - - item()->id}" : null) ?>">title), 15) ?> + causes Gallery3 to display the page + // containing that photo. For now, we just do it for + // the immediate parent so that when you go back up a + // level you're on the right page. ?> + item()->id}" : null) ?>"> + + title, + module::get_var("gallery", "visible_title_length"))) ?> +
  • "> - item()->title), 15) ?> + item()->title, + module::get_var("gallery", "visible_title_length"))) ?>
  • diff --git a/3.0/themes/sobriety/views/photo.html.php b/3.0/themes/sobriety/views/photo.html.php index c5393547..55b5f4cd 100644 --- a/3.0/themes/sobriety/views/photo.html.php +++ b/3.0/themes/sobriety/views/photo.html.php @@ -4,10 +4,23 @@ From b925e8e97f6be02134578efdfd61fb0c547ecd63 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Mon, 15 Nov 2010 06:29:13 +0800 Subject: [PATCH 04/23] Login menu (probably needs to be polished) --- 3.0/themes/sobriety/css/screen.css | 60 ++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/3.0/themes/sobriety/css/screen.css b/3.0/themes/sobriety/css/screen.css index ea8bfaf0..09097d56 100644 --- a/3.0/themes/sobriety/css/screen.css +++ b/3.0/themes/sobriety/css/screen.css @@ -60,10 +60,62 @@ div#g-header { border-bottom: 3px solid #bba; } -div#g-banner { +a#g-logo, form#g-quick-search-form, div#g-site-menu { display: none; } +ul#g-login-menu { + list-style-type: none; + + position: absolute; + top: 0; + right: 0; + + display: block; + margin: 0; + /*padding: 0.5em;*/ + padding: 0; + + width: 20em; + width: 2.5em; + height: 2.5em; + background: url('../images/icons/g-login-menu.png') no-repeat center center; + z-index: 2; +} + +ul#g-login-menu > li { + display: none; + text-align: right; + padding: 2px 0; + width: 20em; + margin-left: -17.6em ; /* -(20-2.5) */ + background-color: #fcfcfc; + color: #000; +} + +ul#g-login-menu > li:first-child { + margin-top: 2.4em; +} + +ul#g-login-menu > li > a { + margin-right: 0.5em; +} + +ul#g-login-menu > li:hover, ul#g-login-menu > li:hover > a { + background-color: #5266f3; + color: #fff; + border-color: #fff; /* a:hover */ +} + +ul#g-login-menu:hover { + /*height: auto;*/ + background-color: #5266f3; +} + +ul#g-login-menu:hover > li { + display: block; +} + ul.g-breadcrumbs { margin: 0; padding: 0; @@ -590,7 +642,7 @@ span.ui-icon-key { background-position: -112px -128px; } -#g-login-menu { +/*#g-login-menu { position: absolute; right: 0; padding: 0; @@ -600,11 +652,11 @@ span.ui-icon-key { background-position: -112px -128px; } display: inline; } #g-login-menu li:first-child { - /*display: none;*/ + display: none; } #g-logo, #g-quick-search-form, #g-site-menu { display: none; -} +}*/ From 7139c5c821bb43f55b4a9350e514e5d0af6f12c8 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Mon, 15 Nov 2010 06:29:25 +0800 Subject: [PATCH 05/23] Do not display the bloc 'actions' when there is not link to display (thanks plasticgoat) --- 3.0/themes/sobriety/views/sobriety_actions.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3.0/themes/sobriety/views/sobriety_actions.html.php b/3.0/themes/sobriety/views/sobriety_actions.html.php index a781a558..2338546b 100644 --- a/3.0/themes/sobriety/views/sobriety_actions.html.php +++ b/3.0/themes/sobriety/views/sobriety_actions.html.php @@ -5,7 +5,7 @@ module::event("site_menu", $menu, $this->theme, ""); ?> -elements['add_menu']->elements) || isset($menu->elements['options_menu']->elements) ): ?> +elements['add_menu']->elements) || !empty($menu->elements['options_menu']->elements) ): ?>

    From 73fbf5118fb3ffd2737b25dd37ad4ec41fb1286c Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Wed, 17 Nov 2010 05:37:05 +0800 Subject: [PATCH 06/23] Some cleanup Some bugfixes : - x-repeat -> repeat-x (thanks plasticgoat) - display the frame around image, even when fullsize is not allowed Re-enable show_full_size (it will probably need some theming) Add a style for header text: configure in G3
    Blah
    (thanks plasticgoat) --- 3.0/themes/sobriety/css/screen.css | 29 ++++++++++--------------- 3.0/themes/sobriety/views/page.html.php | 2 +- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/3.0/themes/sobriety/css/screen.css b/3.0/themes/sobriety/css/screen.css index 09097d56..198c0625 100644 --- a/3.0/themes/sobriety/css/screen.css +++ b/3.0/themes/sobriety/css/screen.css @@ -64,6 +64,15 @@ a#g-logo, form#g-quick-search-form, div#g-site-menu { display: none; } +#g-header-text{ + color: #fff; + font: oblique small-caps bold 1em Georgia,serif; + position: absolute; + left: 15px; + height: 1.5em; + line-height: 1.5em; +} + ul#g-login-menu { list-style-type: none; @@ -108,7 +117,6 @@ ul#g-login-menu > li:hover, ul#g-login-menu > li:hover > a { } ul#g-login-menu:hover { - /*height: auto;*/ background-color: #5266f3; } @@ -503,7 +511,7 @@ span.ui-icon-key { background-position: -112px -128px; } border: none; } -#g-item #g-photo a img { +#g-item #g-photo img { border: 10px solid #fff; -webkit-box-shadow: 3px 3px 0px #b7b7a7; -moz-box-shadow: 3px 3px 0px #b7b7a7; @@ -642,21 +650,6 @@ span.ui-icon-key { background-position: -112px -128px; } -/*#g-login-menu { - position: absolute; - right: 0; - padding: 0; - margin: 0; -} -#g-login-menu li { - display: inline; -} -#g-login-menu li:first-child { - display: none; -} -#g-logo, #g-quick-search-form, #g-site-menu { - display: none; -}*/ @@ -863,7 +856,7 @@ div#g-action-status { height: 22px; width: 0%; background-image: url("../images/backgrounds/pbar-ani.gif"); - background-repeat: x-repeat; + background-repeat: repeat-x; } #g-add-photos-progressbar.stop { background-image: url("../images/backgrounds/pbar-ani-stop.gif"); diff --git a/3.0/themes/sobriety/views/page.html.php b/3.0/themes/sobriety/views/page.html.php index a4610460..7458820f 100644 --- a/3.0/themes/sobriety/views/page.html.php +++ b/3.0/themes/sobriety/views/page.html.php @@ -50,7 +50,7 @@ head() they get combined */ ?> page_subtype == "photo"): ?> script("_DISABLED_jquery.scrollTo.js") ?> - script("_DISABLED_gallery.show_full_size.js") ?> + script("gallery.show_full_size.js") ?> page_subtype == "movie"): ?> script("flowplayer.js") ?> From 9ee5582ad4a793e62fa850d294133979f629c5a2 Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Fri, 19 Nov 2010 05:43:39 +0800 Subject: [PATCH 07/23] Fix video page --- 3.0/themes/sobriety/css/screen.css | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/3.0/themes/sobriety/css/screen.css b/3.0/themes/sobriety/css/screen.css index 198c0625..7418c954 100644 --- a/3.0/themes/sobriety/css/screen.css +++ b/3.0/themes/sobriety/css/screen.css @@ -503,15 +503,17 @@ span.ui-icon-key { background-position: -112px -128px; } background: #b7b7a7; } -#g-item #g-movie { - display: block; -} - #g-item #g-photo a { border: none; } -#g-item #g-photo img { +#g-item #g-movie, +#g-item #g-movie a { + display: block; +} + +#g-item #g-photo img, +#g-item #g-movie object { border: 10px solid #fff; -webkit-box-shadow: 3px 3px 0px #b7b7a7; -moz-box-shadow: 3px 3px 0px #b7b7a7; From 26f882091b818aa495e6282deac9916efb7fb2ad Mon Sep 17 00:00:00 2001 From: Romain LE DISEZ Date: Wed, 24 Nov 2010 06:20:02 +0800 Subject: [PATCH 08/23] [FIX] CRC could be wrong on 32 bits system --- .../downloadalbum/controllers/downloadalbum.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/3.0/modules/downloadalbum/controllers/downloadalbum.php b/3.0/modules/downloadalbum/controllers/downloadalbum.php index 76dd7d8d..73ebd579 100644 --- a/3.0/modules/downloadalbum/controllers/downloadalbum.php +++ b/3.0/modules/downloadalbum/controllers/downloadalbum.php @@ -287,9 +287,13 @@ class downloadalbum_Controller extends Controller { * See http://bugs.php.net/bug.php?id=45028 */ private function fixBug45028($hash) { - return (version_compare(PHP_VERSION, '5.2.7', '<')) - ? (($hash & 0x000000ff) << 24) + (($hash & 0x0000ff00) << 8) - + (($hash & 0x00ff0000) >> 8) + (($hash & 0xff000000) >> 24) - : $hash; + $output = $hash; + + if( version_compare(PHP_VERSION, '5.2.7', '<') ) { + $str = str_pad(dechex($hash), 8, '0', STR_PAD_LEFT); + $output = hexdec($str{6}.$str{7}.$str{4}.$str{5}.$str{2}.$str{3}.$str{0}.$str{1}); + } + + return $output; } } From 5715a6b6850a0977b5b184e72d1851431eaadd12 Mon Sep 17 00:00:00 2001 From: danneh3826 Date: Tue, 23 Nov 2010 05:33:50 +0800 Subject: [PATCH 09/23] added transcode v10 --- .../transcode/controllers/admin_transcode.php | 166 ++++++++++++++ 3.0/modules/transcode/debug.php | 50 +++++ 3.0/modules/transcode/helpers/transcode.php | 59 +++++ .../transcode/helpers/transcode_event.php | 204 ++++++++++++++++++ .../transcode/helpers/transcode_installer.php | 42 ++++ .../transcode/helpers/transcode_task.php | 109 ++++++++++ .../transcode/helpers/transcode_theme.php | 19 ++ .../transcode/models/transcode_resolution.php | 4 + 3.0/modules/transcode/module.info | 3 + .../transcode/views/admin_transcode.html.php | 38 ++++ .../transcode_resolution_variants.html.php | 29 +++ 11 files changed, 723 insertions(+) create mode 100644 3.0/modules/transcode/controllers/admin_transcode.php create mode 100644 3.0/modules/transcode/debug.php create mode 100644 3.0/modules/transcode/helpers/transcode.php create mode 100644 3.0/modules/transcode/helpers/transcode_event.php create mode 100644 3.0/modules/transcode/helpers/transcode_installer.php create mode 100644 3.0/modules/transcode/helpers/transcode_task.php create mode 100644 3.0/modules/transcode/helpers/transcode_theme.php create mode 100644 3.0/modules/transcode/models/transcode_resolution.php create mode 100644 3.0/modules/transcode/module.info create mode 100644 3.0/modules/transcode/views/admin_transcode.html.php create mode 100644 3.0/modules/transcode/views/transcode_resolution_variants.html.php diff --git a/3.0/modules/transcode/controllers/admin_transcode.php b/3.0/modules/transcode/controllers/admin_transcode.php new file mode 100644 index 00000000..b91b1284 --- /dev/null +++ b/3.0/modules/transcode/controllers/admin_transcode.php @@ -0,0 +1,166 @@ + 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 . "
    Click here 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; + } +} diff --git a/3.0/modules/transcode/debug.php b/3.0/modules/transcode/debug.php new file mode 100644 index 00000000..7e9d31a9 --- /dev/null +++ b/3.0/modules/transcode/debug.php @@ -0,0 +1,50 @@ +ffmpeg info"; + $ffmpegPath = whereis("ffmpeg"); + echo "path: " . $ffmpegPath . "
    "; + $version = @shell_exec($ffmpegPath . " -version"); $version = explode("\n", $version); $version = $version[0]; $version = explode(" ", $version); $version = $version[1]; + echo "version: " . $version . "
    "; + echo "codecs:
    " . @shell_exec($ffmpegPath . " -codecs 2>&1") . "

    "; + echo "formats:
    " . @shell_exec($ffmpegPath . " -formats") . "

    "; +} + +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 + ( + ) + +) + + */ \ No newline at end of file diff --git a/3.0/modules/transcode/helpers/transcode.php b/3.0/modules/transcode/helpers/transcode.php new file mode 100644 index 00000000..f6026ec2 --- /dev/null +++ b/3.0/modules/transcode/helpers/transcode.php @@ -0,0 +1,59 @@ +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); + + } + +} diff --git a/3.0/modules/transcode/helpers/transcode_event.php b/3.0/modules/transcode/helpers/transcode_event.php new file mode 100644 index 00000000..774f1275 --- /dev/null +++ b/3.0/modules/transcode/helpers/transcode_event.php @@ -0,0 +1,204 @@ +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); + } + } + } +} diff --git a/3.0/modules/transcode/helpers/transcode_installer.php b/3.0/modules/transcode/helpers/transcode_installer.php new file mode 100644 index 00000000..6501e4f0 --- /dev/null +++ b/3.0/modules/transcode/helpers/transcode_installer.php @@ -0,0 +1,42 @@ +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; + } +} diff --git a/3.0/modules/transcode/helpers/transcode_task.php b/3.0/modules/transcode/helpers/transcode_task.php new file mode 100644 index 00000000..da51bc27 --- /dev/null +++ b/3.0/modules/transcode/helpers/transcode_task.php @@ -0,0 +1,109 @@ +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; + } +} diff --git a/3.0/modules/transcode/helpers/transcode_theme.php b/3.0/modules/transcode/helpers/transcode_theme.php new file mode 100644 index 00000000..371576ac --- /dev/null +++ b/3.0/modules/transcode/helpers/transcode_theme.php @@ -0,0 +1,19 @@ +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; + } + +} \ No newline at end of file diff --git a/3.0/modules/transcode/models/transcode_resolution.php b/3.0/modules/transcode/models/transcode_resolution.php new file mode 100644 index 00000000..f02cf11c --- /dev/null +++ b/3.0/modules/transcode/models/transcode_resolution.php @@ -0,0 +1,4 @@ + + + +
    +

    + +

    + +
    + +
    +
    + + diff --git a/3.0/modules/transcode/views/transcode_resolution_variants.html.php b/3.0/modules/transcode/views/transcode_resolution_variants.html.php new file mode 100644 index 00000000..6c1b5256 --- /dev/null +++ b/3.0/modules/transcode/views/transcode_resolution_variants.html.php @@ -0,0 +1,29 @@ + + +is_movie()): ?> + 0): ?> + + + +

    No alternative resolutions available.

    + + From a7db07e0f944bb3610d9add6a61ed7262ebab8d5 Mon Sep 17 00:00:00 2001 From: mamouneyya Date: Thu, 4 Nov 2010 19:55:08 +0800 Subject: [PATCH 10/23] - group the font properties together in the file - improved odd and even class display - improved comments display for Comment Block module --- 3.0/themes/browny_wind/css/screen.css | 52 +++++++++++++++++---------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/3.0/themes/browny_wind/css/screen.css b/3.0/themes/browny_wind/css/screen.css index 01576252..ddd593a6 100644 --- a/3.0/themes/browny_wind/css/screen.css +++ b/3.0/themes/browny_wind/css/screen.css @@ -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; +} \ No newline at end of file From e8b325878d19786f5a785bd846eca06fde713750 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Mon, 1 Nov 2010 13:28:59 +0800 Subject: [PATCH 11/23] Bugfixes for older browsers. --- .../albumpassword/controllers/albumpassword.php | 14 ++++++++------ 3.0/modules/albumpassword/helpers/MY_item.php | 2 +- .../albumpassword/views/assignpassword.html.php | 17 ----------------- .../albumpassword/views/loginpassword.html.php | 17 ----------------- .../albumpassword/controllers/albumpassword.php | 14 ++++++++------ 3.1/modules/albumpassword/helpers/MY_item.php | 2 +- .../albumpassword/views/assignpassword.html.php | 17 ----------------- .../albumpassword/views/loginpassword.html.php | 17 ----------------- 8 files changed, 18 insertions(+), 82 deletions(-) diff --git a/3.0/modules/albumpassword/controllers/albumpassword.php b/3.0/modules/albumpassword/controllers/albumpassword.php index b014b749..01080fc2 100644 --- a/3.0/modules/albumpassword/controllers/albumpassword.php +++ b/3.0/modules/albumpassword/controllers/albumpassword.php @@ -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 "\n\n\n\n\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 "\n\n\n\n\n"; } else { message::error(t("Password Rejected.")); - json::reply(array("result" => "success")); + print "\n\n\n\n\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; diff --git a/3.0/modules/albumpassword/helpers/MY_item.php b/3.0/modules/albumpassword/helpers/MY_item.php index 3e09a64d..e79717c4 100644 --- a/3.0/modules/albumpassword/helpers/MY_item.php +++ b/3.0/modules/albumpassword/helpers/MY_item.php @@ -36,8 +36,8 @@ class item extends item_Core { } // set access::DENY if necessary. + $view_restrictions = array(); 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); diff --git a/3.0/modules/albumpassword/views/assignpassword.html.php b/3.0/modules/albumpassword/views/assignpassword.html.php index 14cd2767..c1a60b8d 100644 --- a/3.0/modules/albumpassword/views/assignpassword.html.php +++ b/3.0/modules/albumpassword/views/assignpassword.html.php @@ -1,20 +1,3 @@ -
    • diff --git a/3.0/modules/albumpassword/views/loginpassword.html.php b/3.0/modules/albumpassword/views/loginpassword.html.php index 9ebb47fd..750ffbed 100644 --- a/3.0/modules/albumpassword/views/loginpassword.html.php +++ b/3.0/modules/albumpassword/views/loginpassword.html.php @@ -1,20 +1,3 @@ -
      • diff --git a/3.1/modules/albumpassword/controllers/albumpassword.php b/3.1/modules/albumpassword/controllers/albumpassword.php index b014b749..01080fc2 100644 --- a/3.1/modules/albumpassword/controllers/albumpassword.php +++ b/3.1/modules/albumpassword/controllers/albumpassword.php @@ -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 "\n\n\n\n\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 "\n\n\n\n\n"; } else { message::error(t("Password Rejected.")); - json::reply(array("result" => "success")); + print "\n\n\n\n\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; diff --git a/3.1/modules/albumpassword/helpers/MY_item.php b/3.1/modules/albumpassword/helpers/MY_item.php index 3e09a64d..e79717c4 100644 --- a/3.1/modules/albumpassword/helpers/MY_item.php +++ b/3.1/modules/albumpassword/helpers/MY_item.php @@ -36,8 +36,8 @@ class item extends item_Core { } // set access::DENY if necessary. + $view_restrictions = array(); 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); diff --git a/3.1/modules/albumpassword/views/assignpassword.html.php b/3.1/modules/albumpassword/views/assignpassword.html.php index 14cd2767..c1a60b8d 100644 --- a/3.1/modules/albumpassword/views/assignpassword.html.php +++ b/3.1/modules/albumpassword/views/assignpassword.html.php @@ -1,20 +1,3 @@ -
        • diff --git a/3.1/modules/albumpassword/views/loginpassword.html.php b/3.1/modules/albumpassword/views/loginpassword.html.php index 9ebb47fd..750ffbed 100644 --- a/3.1/modules/albumpassword/views/loginpassword.html.php +++ b/3.1/modules/albumpassword/views/loginpassword.html.php @@ -1,20 +1,3 @@ -
          • From 5100e8123a9e1cda670a097b2dac9baf35f7568e Mon Sep 17 00:00:00 2001 From: rWatcher Date: Mon, 1 Nov 2010 13:43:12 +0800 Subject: [PATCH 12/23] CSS Fix. --- .../css/language_flags_sidebar.css | 38 ++++++++----------- .../css/language_flags_sidebar.css | 38 ++++++++----------- 2 files changed, 30 insertions(+), 46 deletions(-) diff --git a/3.0/modules/language_flags/css/language_flags_sidebar.css b/3.0/modules/language_flags/css/language_flags_sidebar.css index 3e6d776b..705dad2d 100644 --- a/3.0/modules/language_flags/css/language_flags_sidebar.css +++ b/3.0/modules/language_flags/css/language_flags_sidebar.css @@ -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; +} \ No newline at end of file diff --git a/3.1/modules/language_flags/css/language_flags_sidebar.css b/3.1/modules/language_flags/css/language_flags_sidebar.css index 3e6d776b..705dad2d 100644 --- a/3.1/modules/language_flags/css/language_flags_sidebar.css +++ b/3.1/modules/language_flags/css/language_flags_sidebar.css @@ -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; +} \ No newline at end of file From 99697342861d17c673659be7b634f4f0946e4b85 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Sat, 6 Nov 2010 13:34:17 +0800 Subject: [PATCH 13/23] Fix for full screen aspect ratio bug (Ticket #1154). --- 3.0/modules/videos/views/movieplayer.html.php | 3 +++ 3.1/modules/videos/views/movieplayer.html.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/3.0/modules/videos/views/movieplayer.html.php b/3.0/modules/videos/views/movieplayer.html.php index b960e1d7..1cf46cda 100644 --- a/3.0/modules/videos/views/movieplayer.html.php +++ b/3.0/modules/videos/views/movieplayer.html.php @@ -19,6 +19,9 @@ provider: "pseudostreaming" }, { + clip: { + scaling: 'fit' + }, plugins: { pseudostreaming: { url: "" diff --git a/3.1/modules/videos/views/movieplayer.html.php b/3.1/modules/videos/views/movieplayer.html.php index b960e1d7..1cf46cda 100644 --- a/3.1/modules/videos/views/movieplayer.html.php +++ b/3.1/modules/videos/views/movieplayer.html.php @@ -19,6 +19,9 @@ provider: "pseudostreaming" }, { + clip: { + scaling: 'fit' + }, plugins: { pseudostreaming: { url: "" From 63873f96cd78f189773c72046feaad1fe6d83580 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Sun, 7 Nov 2010 12:20:50 +0800 Subject: [PATCH 14/23] Hide the album instead of the albums contents. --- 3.0/modules/albumpassword/helpers/MY_item.php | 33 ++++++------------- 3.1/modules/albumpassword/helpers/MY_item.php | 33 ++++++------------- 2 files changed, 20 insertions(+), 46 deletions(-) diff --git a/3.0/modules/albumpassword/helpers/MY_item.php b/3.0/modules/albumpassword/helpers/MY_item.php index e79717c4..79dd3afc 100644 --- a/3.0/modules/albumpassword/helpers/MY_item.php +++ b/3.0/modules/albumpassword/helpers/MY_item.php @@ -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. - $view_restrictions = array(); - if ($deny_access == true) { - 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; diff --git a/3.1/modules/albumpassword/helpers/MY_item.php b/3.1/modules/albumpassword/helpers/MY_item.php index e79717c4..79dd3afc 100644 --- a/3.1/modules/albumpassword/helpers/MY_item.php +++ b/3.1/modules/albumpassword/helpers/MY_item.php @@ -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. - $view_restrictions = array(); - if ($deny_access == true) { - 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; From 73ebd81bc1f5453d5355a13540475719970aa14d Mon Sep 17 00:00:00 2001 From: rWatcher Date: Sun, 7 Nov 2010 13:10:01 +0800 Subject: [PATCH 15/23] Deny access to protected albums and their contents. --- .../albumpassword/helpers/MY_access.php | 57 +++++++++++++++++++ .../albumpassword/helpers/MY_access.php | 57 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 3.0/modules/albumpassword/helpers/MY_access.php create mode 100644 3.1/modules/albumpassword/helpers/MY_access.php diff --git a/3.0/modules/albumpassword/helpers/MY_access.php b/3.0/modules/albumpassword/helpers/MY_access.php new file mode 100644 index 00000000..65052c8a --- /dev/null +++ b/3.0/modules/albumpassword/helpers/MY_access.php @@ -0,0 +1,57 @@ +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); + } + } +} diff --git a/3.1/modules/albumpassword/helpers/MY_access.php b/3.1/modules/albumpassword/helpers/MY_access.php new file mode 100644 index 00000000..65052c8a --- /dev/null +++ b/3.1/modules/albumpassword/helpers/MY_access.php @@ -0,0 +1,57 @@ +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); + } + } +} From 9c7db084ee1c4aa310fc14a1dfbae3b7fb55330c Mon Sep 17 00:00:00 2001 From: rWatcher Date: Sun, 7 Nov 2010 13:10:48 +0800 Subject: [PATCH 16/23] Increase version number two 2, create a new module variable. --- .../helpers/albumpassword_installer.php | 14 ++++++++++++-- 3.0/modules/albumpassword/module.info | 2 +- .../helpers/albumpassword_installer.php | 14 ++++++++++++-- 3.1/modules/albumpassword/module.info | 2 +- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/3.0/modules/albumpassword/helpers/albumpassword_installer.php b/3.0/modules/albumpassword/helpers/albumpassword_installer.php index e59faffb..42af0ddf 100644 --- a/3.0/modules/albumpassword/helpers/albumpassword_installer.php +++ b/3.0/modules/albumpassword/helpers/albumpassword_installer.php @@ -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() { diff --git a/3.0/modules/albumpassword/module.info b/3.0/modules/albumpassword/module.info index 6acdc1dd..cd1262f4 100644 --- a/3.0/modules/albumpassword/module.info +++ b/3.0/modules/albumpassword/module.info @@ -1,3 +1,3 @@ name = "Album Password" description = "Restrict access to individual albums." -version = 1 +version = 2 diff --git a/3.1/modules/albumpassword/helpers/albumpassword_installer.php b/3.1/modules/albumpassword/helpers/albumpassword_installer.php index e59faffb..42af0ddf 100644 --- a/3.1/modules/albumpassword/helpers/albumpassword_installer.php +++ b/3.1/modules/albumpassword/helpers/albumpassword_installer.php @@ -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() { diff --git a/3.1/modules/albumpassword/module.info b/3.1/modules/albumpassword/module.info index 6acdc1dd..cd1262f4 100644 --- a/3.1/modules/albumpassword/module.info +++ b/3.1/modules/albumpassword/module.info @@ -1,3 +1,3 @@ name = "Album Password" description = "Restrict access to individual albums." -version = 1 +version = 2 From e09864291e77400f45969dce87038241bdf3d9fd Mon Sep 17 00:00:00 2001 From: rWatcher Date: Sun, 7 Nov 2010 13:11:13 +0800 Subject: [PATCH 17/23] Don't allow users to protect the root album. --- 3.0/modules/albumpassword/helpers/albumpassword_event.php | 2 +- 3.1/modules/albumpassword/helpers/albumpassword_event.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3.0/modules/albumpassword/helpers/albumpassword_event.php b/3.0/modules/albumpassword/helpers/albumpassword_event.php index dd83c4d9..43747584 100644 --- a/3.0/modules/albumpassword/helpers/albumpassword_event.php +++ b/3.0/modules/albumpassword/helpers/albumpassword_event.php @@ -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") diff --git a/3.1/modules/albumpassword/helpers/albumpassword_event.php b/3.1/modules/albumpassword/helpers/albumpassword_event.php index dd83c4d9..43747584 100644 --- a/3.1/modules/albumpassword/helpers/albumpassword_event.php +++ b/3.1/modules/albumpassword/helpers/albumpassword_event.php @@ -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") From 9f981b56c330b713b10eba5a4713b02f5bc350b8 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Sun, 7 Nov 2010 13:38:57 +0800 Subject: [PATCH 18/23] Created an admin screen. --- .../albumpassword/helpers/albumpassword_event.php | 9 +++++++++ .../albumpassword/helpers/albumpassword_event.php | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/3.0/modules/albumpassword/helpers/albumpassword_event.php b/3.0/modules/albumpassword/helpers/albumpassword_event.php index 43747584..c5ead56a 100644 --- a/3.0/modules/albumpassword/helpers/albumpassword_event.php +++ b/3.0/modules/albumpassword/helpers/albumpassword_event.php @@ -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"))); + } } diff --git a/3.1/modules/albumpassword/helpers/albumpassword_event.php b/3.1/modules/albumpassword/helpers/albumpassword_event.php index 43747584..c5ead56a 100644 --- a/3.1/modules/albumpassword/helpers/albumpassword_event.php +++ b/3.1/modules/albumpassword/helpers/albumpassword_event.php @@ -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"))); + } } From 26a2d9c0f980c744ad4248ce47a9135227b17d5f Mon Sep 17 00:00:00 2001 From: rWatcher Date: Sun, 7 Nov 2010 13:43:09 +0800 Subject: [PATCH 19/23] Modify access to actually use the admin setting. --- 3.0/modules/albumpassword/helpers/MY_access.php | 4 ++-- 3.1/modules/albumpassword/helpers/MY_access.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/3.0/modules/albumpassword/helpers/MY_access.php b/3.0/modules/albumpassword/helpers/MY_access.php index 65052c8a..55f85f33 100644 --- a/3.0/modules/albumpassword/helpers/MY_access.php +++ b/3.0/modules/albumpassword/helpers/MY_access.php @@ -31,7 +31,7 @@ class access extends access_Core { // Begin rWatcher modifications. // This section adds an additional condition onto the view permission that throws a 404 // error if the album has a password assigned. - } elseif ($perm_name == "view") { + } elseif (($perm_name == "view") && (module::get_var("albumpassword", "hideonly") == false)) { $album_item = ""; do { if ($album_item == "") { @@ -43,7 +43,7 @@ class access extends access_Core { } 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) && diff --git a/3.1/modules/albumpassword/helpers/MY_access.php b/3.1/modules/albumpassword/helpers/MY_access.php index 65052c8a..55f85f33 100644 --- a/3.1/modules/albumpassword/helpers/MY_access.php +++ b/3.1/modules/albumpassword/helpers/MY_access.php @@ -31,7 +31,7 @@ class access extends access_Core { // Begin rWatcher modifications. // This section adds an additional condition onto the view permission that throws a 404 // error if the album has a password assigned. - } elseif ($perm_name == "view") { + } elseif (($perm_name == "view") && (module::get_var("albumpassword", "hideonly") == false)) { $album_item = ""; do { if ($album_item == "") { @@ -43,7 +43,7 @@ class access extends access_Core { } 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) && From a77876ec00d53ba6b99027c9a9586eb9866510c7 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Sun, 7 Nov 2010 13:44:07 +0800 Subject: [PATCH 20/23] Create an admin page. --- .../controllers/admin_albumpassword.php | 69 +++++++++++++++++++ .../views/admin_albumpassword.html.php | 9 +++ .../controllers/admin_albumpassword.php | 69 +++++++++++++++++++ .../views/admin_albumpassword.html.php | 9 +++ 4 files changed, 156 insertions(+) create mode 100644 3.0/modules/albumpassword/controllers/admin_albumpassword.php create mode 100644 3.0/modules/albumpassword/views/admin_albumpassword.html.php create mode 100644 3.1/modules/albumpassword/controllers/admin_albumpassword.php create mode 100644 3.1/modules/albumpassword/views/admin_albumpassword.html.php diff --git a/3.0/modules/albumpassword/controllers/admin_albumpassword.php b/3.0/modules/albumpassword/controllers/admin_albumpassword.php new file mode 100644 index 00000000..db134c66 --- /dev/null +++ b/3.0/modules/albumpassword/controllers/admin_albumpassword.php @@ -0,0 +1,69 @@ +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"); + } +} \ No newline at end of file diff --git a/3.0/modules/albumpassword/views/admin_albumpassword.html.php b/3.0/modules/albumpassword/views/admin_albumpassword.html.php new file mode 100644 index 00000000..05e46454 --- /dev/null +++ b/3.0/modules/albumpassword/views/admin_albumpassword.html.php @@ -0,0 +1,9 @@ + +

            + +

            +
            +
            +

            + +
            diff --git a/3.1/modules/albumpassword/controllers/admin_albumpassword.php b/3.1/modules/albumpassword/controllers/admin_albumpassword.php new file mode 100644 index 00000000..db134c66 --- /dev/null +++ b/3.1/modules/albumpassword/controllers/admin_albumpassword.php @@ -0,0 +1,69 @@ +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"); + } +} \ No newline at end of file diff --git a/3.1/modules/albumpassword/views/admin_albumpassword.html.php b/3.1/modules/albumpassword/views/admin_albumpassword.html.php new file mode 100644 index 00000000..05e46454 --- /dev/null +++ b/3.1/modules/albumpassword/views/admin_albumpassword.html.php @@ -0,0 +1,9 @@ + +

            + +

            +
            +
            +

            + +
            From 06725f6ce1285093ca042aed38ca301399ada6f2 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Sun, 7 Nov 2010 13:48:21 +0800 Subject: [PATCH 21/23] Cleaning up the code. --- .../controllers/admin_albumpassword.php | 16 ++++++++-------- 3.0/modules/albumpassword/helpers/MY_access.php | 1 + .../helpers/albumpassword_installer.php | 4 ++-- .../controllers/admin_albumpassword.php | 16 ++++++++-------- 3.1/modules/albumpassword/helpers/MY_access.php | 1 + .../helpers/albumpassword_installer.php | 4 ++-- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/3.0/modules/albumpassword/controllers/admin_albumpassword.php b/3.0/modules/albumpassword/controllers/admin_albumpassword.php index db134c66..425f9ed9 100644 --- a/3.0/modules/albumpassword/controllers/admin_albumpassword.php +++ b/3.0/modules/albumpassword/controllers/admin_albumpassword.php @@ -39,9 +39,9 @@ class Admin_Albumpassword_Controller extends Admin_Controller { // 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")); + $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")); @@ -56,14 +56,14 @@ class Admin_Albumpassword_Controller extends Admin_Controller { // Prevent Cross Site Request Forgery access::verify_csrf(); - // Retrieve submitted form data. - if (Input::instance()->post("hideonly") == false) { + // Retrieve submitted form data. + if (Input::instance()->post("hideonly") == false) { module::set_var("albumpassword", "hideonly", false); - } else { + } 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"); } -} \ No newline at end of file +} diff --git a/3.0/modules/albumpassword/helpers/MY_access.php b/3.0/modules/albumpassword/helpers/MY_access.php index 55f85f33..0d524624 100644 --- a/3.0/modules/albumpassword/helpers/MY_access.php +++ b/3.0/modules/albumpassword/helpers/MY_access.php @@ -28,6 +28,7 @@ class access extends access_Core { } else { self::forbidden(); } + // Begin rWatcher modifications. // This section adds an additional condition onto the view permission that throws a 404 // error if the album has a password assigned. diff --git a/3.0/modules/albumpassword/helpers/albumpassword_installer.php b/3.0/modules/albumpassword/helpers/albumpassword_installer.php index 42af0ddf..1fd20d89 100644 --- a/3.0/modules/albumpassword/helpers/albumpassword_installer.php +++ b/3.0/modules/albumpassword/helpers/albumpassword_installer.php @@ -30,7 +30,7 @@ class albumpassword_installer { // 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); } @@ -38,7 +38,7 @@ class albumpassword_installer { 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); } diff --git a/3.1/modules/albumpassword/controllers/admin_albumpassword.php b/3.1/modules/albumpassword/controllers/admin_albumpassword.php index db134c66..425f9ed9 100644 --- a/3.1/modules/albumpassword/controllers/admin_albumpassword.php +++ b/3.1/modules/albumpassword/controllers/admin_albumpassword.php @@ -39,9 +39,9 @@ class Admin_Albumpassword_Controller extends Admin_Controller { // 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")); + $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")); @@ -56,14 +56,14 @@ class Admin_Albumpassword_Controller extends Admin_Controller { // Prevent Cross Site Request Forgery access::verify_csrf(); - // Retrieve submitted form data. - if (Input::instance()->post("hideonly") == false) { + // Retrieve submitted form data. + if (Input::instance()->post("hideonly") == false) { module::set_var("albumpassword", "hideonly", false); - } else { + } 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"); } -} \ No newline at end of file +} diff --git a/3.1/modules/albumpassword/helpers/MY_access.php b/3.1/modules/albumpassword/helpers/MY_access.php index 55f85f33..0d524624 100644 --- a/3.1/modules/albumpassword/helpers/MY_access.php +++ b/3.1/modules/albumpassword/helpers/MY_access.php @@ -28,6 +28,7 @@ class access extends access_Core { } else { self::forbidden(); } + // Begin rWatcher modifications. // This section adds an additional condition onto the view permission that throws a 404 // error if the album has a password assigned. diff --git a/3.1/modules/albumpassword/helpers/albumpassword_installer.php b/3.1/modules/albumpassword/helpers/albumpassword_installer.php index 42af0ddf..1fd20d89 100644 --- a/3.1/modules/albumpassword/helpers/albumpassword_installer.php +++ b/3.1/modules/albumpassword/helpers/albumpassword_installer.php @@ -30,7 +30,7 @@ class albumpassword_installer { // 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); } @@ -38,7 +38,7 @@ class albumpassword_installer { 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); } From 80f2f225139d80cbee04bf6a7fe9d9a72bde3341 Mon Sep 17 00:00:00 2001 From: rWatcher Date: Mon, 8 Nov 2010 13:45:54 +0800 Subject: [PATCH 22/23] Minor fix. --- 3.0/modules/albumpassword/helpers/MY_access.php | 6 +++--- 3.1/modules/albumpassword/helpers/MY_access.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/3.0/modules/albumpassword/helpers/MY_access.php b/3.0/modules/albumpassword/helpers/MY_access.php index 0d524624..faf6c1c0 100644 --- a/3.0/modules/albumpassword/helpers/MY_access.php +++ b/3.0/modules/albumpassword/helpers/MY_access.php @@ -30,9 +30,9 @@ class access extends access_Core { } // Begin rWatcher modifications. - // This section adds an additional condition onto the view permission that throws a 404 - // error if the album has a password assigned. - } elseif (($perm_name == "view") && (module::get_var("albumpassword", "hideonly") == false)) { + // 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 == "") { diff --git a/3.1/modules/albumpassword/helpers/MY_access.php b/3.1/modules/albumpassword/helpers/MY_access.php index 0d524624..faf6c1c0 100644 --- a/3.1/modules/albumpassword/helpers/MY_access.php +++ b/3.1/modules/albumpassword/helpers/MY_access.php @@ -30,9 +30,9 @@ class access extends access_Core { } // Begin rWatcher modifications. - // This section adds an additional condition onto the view permission that throws a 404 - // error if the album has a password assigned. - } elseif (($perm_name == "view") && (module::get_var("albumpassword", "hideonly") == false)) { + // 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 == "") { From b7444e5cfc7e34b5fa2c11172918d2357240569e Mon Sep 17 00:00:00 2001 From: rWatcher Date: Sun, 14 Nov 2010 14:42:29 +0800 Subject: [PATCH 23/23] Initial commit of TagsInAlbum module. --- .../tagsinalbum/helpers/tagsinalbum_block.php | 50 +++++++++++++++++++ 3.0/modules/tagsinalbum/module.info | 3 ++ .../views/tagsinalbum_sidebar.html.php | 28 +++++++++++ .../tagsinalbum/helpers/tagsinalbum_block.php | 50 +++++++++++++++++++ 3.1/modules/tagsinalbum/module.info | 3 ++ .../views/tagsinalbum_sidebar.html.php | 28 +++++++++++ 6 files changed, 162 insertions(+) create mode 100644 3.0/modules/tagsinalbum/helpers/tagsinalbum_block.php create mode 100644 3.0/modules/tagsinalbum/module.info create mode 100644 3.0/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php create mode 100644 3.1/modules/tagsinalbum/helpers/tagsinalbum_block.php create mode 100644 3.1/modules/tagsinalbum/module.info create mode 100644 3.1/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php diff --git a/3.0/modules/tagsinalbum/helpers/tagsinalbum_block.php b/3.0/modules/tagsinalbum/helpers/tagsinalbum_block.php new file mode 100644 index 00000000..d923bc15 --- /dev/null +++ b/3.0/modules/tagsinalbum/helpers/tagsinalbum_block.php @@ -0,0 +1,50 @@ + 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; + } +} diff --git a/3.0/modules/tagsinalbum/module.info b/3.0/modules/tagsinalbum/module.info new file mode 100644 index 00000000..94b7699b --- /dev/null +++ b/3.0/modules/tagsinalbum/module.info @@ -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 diff --git a/3.0/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php b/3.0/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php new file mode 100644 index 00000000..803e46ee --- /dev/null +++ b/3.0/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php @@ -0,0 +1,28 @@ + +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 "" . $one_tag[0] . ""; + } +?> diff --git a/3.1/modules/tagsinalbum/helpers/tagsinalbum_block.php b/3.1/modules/tagsinalbum/helpers/tagsinalbum_block.php new file mode 100644 index 00000000..d923bc15 --- /dev/null +++ b/3.1/modules/tagsinalbum/helpers/tagsinalbum_block.php @@ -0,0 +1,50 @@ + 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; + } +} diff --git a/3.1/modules/tagsinalbum/module.info b/3.1/modules/tagsinalbum/module.info new file mode 100644 index 00000000..94b7699b --- /dev/null +++ b/3.1/modules/tagsinalbum/module.info @@ -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 diff --git a/3.1/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php b/3.1/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php new file mode 100644 index 00000000..803e46ee --- /dev/null +++ b/3.1/modules/tagsinalbum/views/tagsinalbum_sidebar.html.php @@ -0,0 +1,28 @@ + +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 "" . $one_tag[0] . ""; + } +?>