diff --git a/3.0/modules/downloadalbum/controllers/downloadalbum.php b/3.0/modules/downloadalbum/controllers/downloadalbum.php index 73ebd579..79df86ff 100644 --- a/3.0/modules/downloadalbum/controllers/downloadalbum.php +++ b/3.0/modules/downloadalbum/controllers/downloadalbum.php @@ -174,7 +174,8 @@ class downloadalbum_Controller extends Controller { continue; } - $i_relative_path = str_replace($container_realpath.'/', '', $i_realpath); + $i_relative_path = str_replace($container_realpath.DIRECTORY_SEPARATOR, '', $i_realpath); + $i_relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $i_relative_path); $files[$i_relative_path] = $i_realpath; } diff --git a/3.0/themes/sobriety/css/comment.css b/3.0/themes/sobriety/css/comment.css new file mode 100644 index 00000000..2aeb1794 --- /dev/null +++ b/3.0/themes/sobriety/css/comment.css @@ -0,0 +1,84 @@ +#g-content #g-comments { + display: block; + margin-top: 2em; + position: relative; +} + +#g-content #g-comments h2 { + margin: 0; +} + +#g-content #g-comments #g-add-comment { + position: absolute; + right: 0; + top: 2px; +} + +#g-content #g-comments ul { + list-style-type: none; + margin: 0; + padding: 0; +} + +#g-content #g-comments #g-comment-detail > ul li { + padding: 1em 0; + border-bottom: 1px dotted #aaab9b; +} + +#g-content #g-comments ul li .g-author { + margin: 0 0 0.5em; + font-style: italic; + font-width: normal; + /*font-size: 85%;*/ +} + +#g-content #g-comments ul li .g-author a:first-child { + border: none; +} + +#g-content #g-comments ul li .g-author a img.g-avatar { + width: 13px; + height: 13px; + margin-right: 5px; +} + +#g-content #g-comments ul li div { + margin-left: 23px; +} + +#g-content #g-comments #g-comment-detail #g-comment-form fieldset { + border: 0; + margin: 1em 0 0 0; + padding: 0; +} + +#g-content #g-comments #g-comment-detail #g-comment-form fieldset legend { + font-size: 2em; + margin-bottom: 0.5em; +} + +#g-content #g-comments #g-comment-detail #g-comment-form fieldset ul li { + clear: both; + padding-top: 0.5em; +} + +#g-content #g-comments #g-comment-detail #g-comment-form fieldset ul li label { + float: left; + width: 30%; + padding-top: 5px; +} + +#g-content #g-comments #g-comment-detail #g-comment-form fieldset ul li input[type="text"] { + float: left; + width: 40%; +} + +#g-content #g-comments #g-comment-detail #g-comment-form fieldset ul li input[type="submit"] { + float: right; +} + +#g-content #g-comments #g-comment-detail #g-comment-form fieldset ul li textarea { + float: left; + width: 69%; + height: 10em; +} diff --git a/3.0/themes/sobriety/css/screen.css b/3.0/themes/sobriety/css/screen.css index bf527138..3fb13ede 100644 --- a/3.0/themes/sobriety/css/screen.css +++ b/3.0/themes/sobriety/css/screen.css @@ -593,7 +593,8 @@ span.ui-icon-key { background-position: -112px -128px; } } #g-item .g-block { - display: none; + display: block; + margin: auto; } #g-item .g-block#g-metadata { @@ -621,9 +622,6 @@ span.ui-icon-key { background-position: -112px -128px; } padding: 0; } -#g-item .g-block#g-comments { - display: block; -} diff --git a/3.0/themes/sobriety/images/avatar.jpg b/3.0/themes/sobriety/images/avatar.jpg new file mode 100644 index 00000000..17a31829 Binary files /dev/null and b/3.0/themes/sobriety/images/avatar.jpg differ diff --git a/3.0/themes/sobriety/images/ico-denied-inactive.png b/3.0/themes/sobriety/images/ico-denied-inactive.png new file mode 100644 index 00000000..56db3ff5 Binary files /dev/null and b/3.0/themes/sobriety/images/ico-denied-inactive.png differ diff --git a/3.0/themes/sobriety/images/ico-denied-passive.png b/3.0/themes/sobriety/images/ico-denied-passive.png new file mode 100644 index 00000000..1e992230 Binary files /dev/null and b/3.0/themes/sobriety/images/ico-denied-passive.png differ diff --git a/3.0/themes/sobriety/images/ico-denied.png b/3.0/themes/sobriety/images/ico-denied.png new file mode 100644 index 00000000..08f24936 Binary files /dev/null and b/3.0/themes/sobriety/images/ico-denied.png differ diff --git a/3.0/themes/sobriety/images/ico-error.png b/3.0/themes/sobriety/images/ico-error.png new file mode 100644 index 00000000..c37bd062 Binary files /dev/null and b/3.0/themes/sobriety/images/ico-error.png differ diff --git a/3.0/themes/sobriety/images/ico-info.png b/3.0/themes/sobriety/images/ico-info.png new file mode 100644 index 00000000..12cd1aef Binary files /dev/null and b/3.0/themes/sobriety/images/ico-info.png differ diff --git a/3.0/themes/sobriety/images/ico-lock.png b/3.0/themes/sobriety/images/ico-lock.png new file mode 100644 index 00000000..2ebc4f6f Binary files /dev/null and b/3.0/themes/sobriety/images/ico-lock.png differ diff --git a/3.0/themes/sobriety/images/ico-separator-rtl.gif b/3.0/themes/sobriety/images/ico-separator-rtl.gif new file mode 100644 index 00000000..d9061a46 Binary files /dev/null and b/3.0/themes/sobriety/images/ico-separator-rtl.gif differ diff --git a/3.0/themes/sobriety/images/ico-separator.gif b/3.0/themes/sobriety/images/ico-separator.gif new file mode 100644 index 00000000..3de2d0d3 Binary files /dev/null and b/3.0/themes/sobriety/images/ico-separator.gif differ diff --git a/3.0/themes/sobriety/images/ico-success-inactive.png b/3.0/themes/sobriety/images/ico-success-inactive.png new file mode 100644 index 00000000..74b2032f Binary files /dev/null and b/3.0/themes/sobriety/images/ico-success-inactive.png differ diff --git a/3.0/themes/sobriety/images/ico-success-passive.png b/3.0/themes/sobriety/images/ico-success-passive.png new file mode 100644 index 00000000..dc8d1ded Binary files /dev/null and b/3.0/themes/sobriety/images/ico-success-passive.png differ diff --git a/3.0/themes/sobriety/images/ico-success.png b/3.0/themes/sobriety/images/ico-success.png new file mode 100644 index 00000000..a9925a06 Binary files /dev/null and b/3.0/themes/sobriety/images/ico-success.png differ diff --git a/3.0/themes/sobriety/images/ico-warning.png b/3.0/themes/sobriety/images/ico-warning.png new file mode 100644 index 00000000..628cf2da Binary files /dev/null and b/3.0/themes/sobriety/images/ico-warning.png differ diff --git a/3.0/themes/sobriety/images/icon_pushpin.gif b/3.0/themes/sobriety/images/icon_pushpin.gif deleted file mode 100644 index b9e8461e..00000000 Binary files a/3.0/themes/sobriety/images/icon_pushpin.gif and /dev/null differ diff --git a/3.0/themes/sobriety/images/icons/g-login-menu.png b/3.0/themes/sobriety/images/icons/g-login-menu.png new file mode 100644 index 00000000..33e686cb Binary files /dev/null and b/3.0/themes/sobriety/images/icons/g-login-menu.png differ diff --git a/3.0/themes/sobriety/images/loading-large.gif b/3.0/themes/sobriety/images/loading-large.gif new file mode 100644 index 00000000..cc70a7a8 Binary files /dev/null and b/3.0/themes/sobriety/images/loading-large.gif differ diff --git a/3.0/themes/sobriety/images/loading-small.gif b/3.0/themes/sobriety/images/loading-small.gif new file mode 100644 index 00000000..d0bce154 Binary files /dev/null and b/3.0/themes/sobriety/images/loading-small.gif differ diff --git a/3.1/modules/downloadalbum/controllers/downloadalbum.php b/3.1/modules/downloadalbum/controllers/downloadalbum.php index c2f939f7..79df86ff 100644 --- a/3.1/modules/downloadalbum/controllers/downloadalbum.php +++ b/3.1/modules/downloadalbum/controllers/downloadalbum.php @@ -22,30 +22,55 @@ class downloadalbum_Controller extends Controller { /** * Generate a ZIP on-the-fly. */ - public function zip($id) { - $album = $this->init($id); - $files = $this->getFilesList($album); + public function zip($container_type, $id) { + switch($container_type) { + case "album": + $container = ORM::factory("item", $id); + if (!$container->is_album()) { + throw new Kohana_Exception('container is not an album: '.$container->relative_path()); + } + + $zipname = (empty($container->name)) + ? 'Gallery.zip' // @todo purified_version_of($container->title).'.zip' + : $container->name.'.zip'; + break; + + case "tag": + // @todo: if the module is not installed, it crash + $container = ORM::factory("tag", $id); + if (is_null($container->name)) { + throw new Kohana_Exception('container is not a tag: '.$id); + } + + $zipname = $container->name.'.zip'; + break; + + default: + throw new Kohana_Exception('unhandled container type: '.$container_type); + } + + $files = $this->getFilesList($container); // Calculate ZIP size (look behind for details) $zipsize = 22; - foreach($files as $f) { - $zipsize += 76 + 2*strlen($f) + filesize($f); + foreach($files as $f_name => $f_path) { + $zipsize += 76 + 2*strlen($f_name) + filesize($f_path); } // Send headers $this->prepareOutput(); - $this->sendHeaders($album->name.'.zip', $zipsize); + $this->sendHeaders($zipname, $zipsize); // Generate and send ZIP file // http://www.pkware.com/documents/casestudies/APPNOTE.TXT (v6.3.2) $lfh_offset = 0; $cds = ''; $cds_offset = 0; - foreach($files as $f) { - $f_namelen = strlen($f); - $f_size = filesize($f); - $f_mtime = $this->unix2dostime(filemtime($f)); - $f_crc32 = $this->fixBug45028(hexdec(hash_file('crc32b', $f, false))); + foreach($files as $f_name => $f_path) { + $f_namelen = strlen($f_name); + $f_size = filesize($f_path); + $f_mtime = $this->unix2dostime(filemtime($f_path)); + $f_crc32 = $this->fixBug45028(hexdec(hash_file('crc32b', $f_path, false))); // Local file header echo pack('VvvvVVVVvva' . $f_namelen, @@ -60,12 +85,12 @@ class downloadalbum_Controller extends Controller { $f_namelen, // file name length (2 bytes) 0, // extra field length (2 bytes) - $f // file name (variable size) + $f_name // file name (variable size) // extra field (variable size) => n/a ); // File data - readfile($f); + readfile($f_path); // Data descriptor (n/a) @@ -88,7 +113,7 @@ class downloadalbum_Controller extends Controller { 0x81b40000, // external file attributes (4 bytes) => chmod 664 $lfh_offset, // relative offset of local header (4 bytes) - $f // file name (variable size) + $f_name // file name (variable size) // extra field (variable size) => n/a // file comment (variable size) => n/a ); @@ -128,59 +153,58 @@ class downloadalbum_Controller extends Controller { } - /** - * Init - */ - private function init($id) { - $item = ORM::factory("item", $id); - - // Only send an album - if (!$item->is_album()) { - // @todo: throw an exception? - Kohana::log('error', 'item is not an album: '.$item->relative_path()); - exit; - } - - // Must have view_full to download the originals files - access::required("view_full", $item); - - return $item; - } - /** * Return the files that must be included in the archive. */ - private function getFilesList($album) { + private function getFilesList($container) { $files = array(); - // Go to the parent of album so the ZIP will not contains all the - // server hierarchy - if (!chdir($album->file_path().'/../')) { - // @todo: throw an exception? - Kohana::log('error', 'unable to chdir('.$item->file_path().'/../)'); - exit; - } - $cwd = getcwd(); + if( $container instanceof Item_Model && $container->is_album() ) { + $container_realpath = realpath($container->file_path().'/../'); - $items = $album->viewable() - ->descendants(null, null, array(array("type", "<>", "album"))); - foreach($items as $i) { - if (!access::can('view_full', $i)) { - continue; + $items = $container->viewable() + ->descendants(null, null, array(array("type", "<>", "album"))); + foreach($items as $i) { + if (!access::can('view_full', $i)) { + continue; + } + + $i_realpath = realpath($i->file_path()); + if (!is_readable($i_realpath)) { + continue; + } + + $i_relative_path = str_replace($container_realpath.DIRECTORY_SEPARATOR, '', $i_realpath); + $i_relative_path = str_replace(DIRECTORY_SEPARATOR, '/', $i_relative_path); + $files[$i_relative_path] = $i_realpath; } - $relative_path = str_replace($cwd.'/', '', realpath($i->file_path())); - if (!is_readable($relative_path)) { - continue; - } + } else if( $container instanceof Tag_Model ) { + $items = $container->items(); + foreach($items as $i) { + if (!access::can('view_full', $i)) { + continue; + } - $files[] = $relative_path; + if( $i->is_album() ) { + foreach($this->getFilesList($i) as $f_name => $f_path) { + $files[$container->name.'/'.$f_name] = $f_path; + } + + } else { + $i_realpath = realpath($i->file_path()); + if (!is_readable($i_realpath)) { + continue; + } + + $i_relative_path = $container->name.'/'.$i->name; + $files[$i_relative_path] = $i_realpath; + } + } } if (count($files) === 0) { - // @todo: throw an exception? - Kohana::log('error', 'no zippable files in ['.$album->relative_path().']'); - exit; + throw new Kohana_Exception('no zippable files in ['.$container->name.']'); } return $files; @@ -264,9 +288,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; } } diff --git a/3.1/modules/downloadalbum/helpers/downloadalbum_event.php b/3.1/modules/downloadalbum/helpers/downloadalbum_event.php index e2fe4420..e58512ac 100644 --- a/3.1/modules/downloadalbum/helpers/downloadalbum_event.php +++ b/3.1/modules/downloadalbum/helpers/downloadalbum_event.php @@ -19,14 +19,22 @@ */ class downloadalbum_event_Core { static function album_menu($menu, $theme) { - if (access::can("view_full", $theme->item)) { - $downloadLink = url::site("downloadalbum/zip/{$theme->item->id}"); - $menu - ->append(Menu::factory("link") - ->id("downloadalbum") - ->label(t("Download Album")) - ->url($downloadLink) - ->css_id("g-download-album-link")); - } + $downloadLink = url::site("downloadalbum/zip/album/{$theme->item->id}"); + $menu + ->append(Menu::factory("link") + ->id("downloadalbum") + ->label(t("Download Album")) + ->url($downloadLink) + ->css_id("g-download-album-link")); } + + static function tag_menu($menu, $theme) { + $downloadLink = url::site("downloadalbum/zip/tag/{$theme->tag()->id}"); + $menu + ->append(Menu::factory("link") + ->id("downloadalbum") + ->label(t("Download Album")) + ->url($downloadLink) + ->css_id("g-download-album-link")); + } } diff --git a/3.1/modules/downloadalbum/helpers/downloadalbum_theme.php b/3.1/modules/downloadalbum/helpers/downloadalbum_theme.php index 2fd23552..d88d8a52 100644 --- a/3.1/modules/downloadalbum/helpers/downloadalbum_theme.php +++ b/3.1/modules/downloadalbum/helpers/downloadalbum_theme.php @@ -19,8 +19,6 @@ */ class downloadalbum_theme { static function head($theme) { - if ($theme->item && access::can("view_full", $theme->item)) { - $theme->css("downloadalbum_menu.css"); - } + $theme->css("downloadalbum_menu.css"); } } diff --git a/3.1/modules/downloadalbum/module.info b/3.1/modules/downloadalbum/module.info index 177ad4a8..11c52ba2 100644 --- a/3.1/modules/downloadalbum/module.info +++ b/3.1/modules/downloadalbum/module.info @@ -1,3 +1,3 @@ name = "DownloadAlbum" description = "Displays a link to download a ZIP archive of the current album." -version = 1 +version = 2