Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed Dec 2, 2009
2 parents 53df0df + 6fa8807 commit c803cb2
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion modules/gallery/config/routes.php
Expand Up @@ -25,4 +25,4 @@
$config["^form/(edit|add)/(\w+)/(.*)$"] = "$2/form_$1/$3";

// Default page is the root album
$config["_default"] = "albums/1";
$config["_default"] = "albums";
2 changes: 2 additions & 0 deletions modules/gallery/controllers/admin_theme_options.php
Expand Up @@ -58,6 +58,8 @@ public function save() {
module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value);
module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value);

module::event("theme_edit_form_completed", $form);

message::success(t("Updated theme details"));
url::redirect("admin/theme_options");
} else {
Expand Down
11 changes: 10 additions & 1 deletion modules/gallery/controllers/albums.php
Expand Up @@ -18,7 +18,16 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Albums_Controller extends Items_Controller {
public function _show($album) {
public function index() {
$this->show(ORM::factory("item", 1));
}

public function show($album) {
if (!is_object($album)) {
// show() must be public because we route to it in url::parse_url(), so make
// sure that we're actually receiving an object
Kohana::show_404();
}
$page_size = module::get_var("gallery", "page_size", 9);
if (!access::can("view", $album)) {
if ($album->id == 1) {
Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/controllers/file_proxy.php
Expand Up @@ -112,7 +112,7 @@ public function __call($function, $args) {
Session::abort_save();

// Dump out the image. If the item is a movie, then its thumbnail will be a JPG.
if (in_array($item->mime_type, array("video/x-flv", "video/mp4"))) {
if ($item->is_movie() && $type != "albums") {
header("Content-type: image/jpeg");
} else {
header("Content-Type: $item->mime_type");
Expand Down
8 changes: 5 additions & 3 deletions modules/gallery/controllers/items.php
Expand Up @@ -23,10 +23,12 @@ public function __call($function, $args) {
if (!$item->loaded()) {
throw new Kohana_404_Exception();
}

// Redirect to the more specific resource type, since it will render
// differently. We could also just delegate here, but it feels more appropriate
// to have a single canonical resource mapping.
// differently. We can't delegate here because we may have gotten to this
// page via /items/<id> which means that we don't have a type-specific controller. Also, we
// want to drive a single canonical resource mapping where possible.
access::required("view", $item);
return $this->_show($item);
url::redirect($item->abs_url());
}
}
7 changes: 6 additions & 1 deletion modules/gallery/controllers/movies.php
Expand Up @@ -18,7 +18,12 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Movies_Controller extends Items_Controller {
public function _show($movie) {
public function show($movie) {
if (!is_object($movie)) {
// show() must be public because we route to it in url::parse_url(), so make
// sure that we're actually receiving an object
Kohana::show_404();
}
access::required("view", $movie);

$where = array(array("type", "!=", "album"));
Expand Down
7 changes: 6 additions & 1 deletion modules/gallery/controllers/photos.php
Expand Up @@ -18,7 +18,12 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Photos_Controller extends Items_Controller {
public function _show($photo) {
public function show($photo) {
if (!is_object($photo)) {
// show() must be public because we route to it in url::parse_url(), so make
// sure that we're actually receiving an object
Kohana::show_404();
}
access::required("view", $photo);

$where = array(array("type", "!=", "album"));
Expand Down
3 changes: 2 additions & 1 deletion modules/gallery/helpers/MY_url.php
Expand Up @@ -35,7 +35,8 @@ static function parse_url() {
if ($item && $item->loaded()) {
Router::$controller = "{$item->type}s";
Router::$controller_path = MODPATH . "gallery/controllers/{$item->type}s.php";
Router::$method = $item->id;
Router::$method = "show";
Router::$arguments = array($item);
}
}

Expand Down
3 changes: 2 additions & 1 deletion modules/gallery/helpers/access.php
Expand Up @@ -609,7 +609,8 @@ private static function _update_htaccess_files($album, $group, $perm_name, $valu
$dirs[] = dirname($album->thumb_path());
}

$base_url = url::site("file_proxy");
$base_url = url::site("?kohana_uri=/file_proxy");
$base_url = str_replace("/?", "?", $base_url);
foreach ($dirs as $dir) {
if ($value === self::DENY) {
$fp = fopen("$dir/.htaccess", "w+");
Expand Down
4 changes: 4 additions & 0 deletions modules/gallery/helpers/theme.php
Expand Up @@ -86,6 +86,10 @@ static function get_edit_form_admin() {
->value(module::get_var("gallery", "footer_text"));
$group->checkbox("show_credits")->label(t("Show site credits"))->id("g-footer-text")
->checked(module::get_var("gallery", "show_credits"));

module::event("theme_edit_form", $form);

$group = $form->group("buttons");
$group->submit("")->value(t("Save"));
return $form;
}
Expand Down

0 comments on commit c803cb2

Please sign in to comment.