Permalink
Browse files

Merge pull request #69 from floridave/master

new modules: about, addthis, all_tags and carousel.
  • Loading branch information...
2 parents 126658b + db073dd commit 4437d22a73a1de23a90279256a93f5d1880989ed @bharat bharat committed May 15, 2011
Showing with 1,597 additions and 0 deletions.
  1. +28 −0 3.0/modules/about/controllers/about.php
  2. +61 −0 3.0/modules/about/controllers/admin_about.php
  3. +2 −0 3.0/modules/about/css/about.css
  4. +39 −0 3.0/modules/about/helpers/about_block.php
  5. +37 −0 3.0/modules/about/helpers/about_event.php
  6. +26 −0 3.0/modules/about/helpers/about_installer.php
  7. +6 −0 3.0/modules/about/module.info
  8. +3 −0 3.0/modules/about/views/about.html.php
  9. +2 −0 3.0/modules/about/views/about_block.html.php
  10. +5 −0 3.0/modules/about/views/admin_about.html.php
  11. +29 −0 3.0/modules/addthis/config/addthis.php
  12. +123 −0 3.0/modules/addthis/controllers/addthis.php
  13. +26 −0 3.0/modules/addthis/controllers/admin_addthis.php
  14. +3 −0 3.0/modules/addthis/css/addthis_menu.css
  15. +48 −0 3.0/modules/addthis/helpers/addthis_event.php
  16. +45 −0 3.0/modules/addthis/helpers/addthis_installer.php
  17. +29 −0 3.0/modules/addthis/helpers/addthis_theme.php
  18. BIN 3.0/modules/addthis/images/addthis_logo.png
  19. +22 −0 3.0/modules/addthis/models/addthis_proxy.php
  20. +3 −0 3.0/modules/addthis/module.info
  21. +22 −0 3.0/modules/addthis/views/admin_addthis.html.php
  22. +56 −0 3.0/modules/all_tags/controllers/all_tags.php
  23. +2 −0 3.0/modules/all_tags/css/all_tags.css
  24. +29 −0 3.0/modules/all_tags/helpers/all_tags_event.php
  25. +24 −0 3.0/modules/all_tags/helpers/all_tags_theme.php
  26. +7 −0 3.0/modules/all_tags/module.info
  27. +44 −0 3.0/modules/all_tags/views/all_tags.html.php
  28. +183 −0 3.0/modules/carousel/controllers/admin_carousel.php
  29. +30 −0 3.0/modules/carousel/css/carousel.css
  30. +61 −0 3.0/modules/carousel/helpers/carousel_block.php
  31. +28 −0 3.0/modules/carousel/helpers/carousel_event.php
  32. +24 −0 3.0/modules/carousel/helpers/carousel_theme.php
  33. +1 −0 3.0/modules/carousel/js/jcarousellite.min.js
  34. +364 −0 3.0/modules/carousel/js/jcarousellite_orig.js
  35. +11 −0 3.0/modules/carousel/js/jquery.mousewheel.min.js
  36. +7 −0 3.0/modules/carousel/module.info
  37. +23 −0 3.0/modules/carousel/views/admin_carousel.html.php
  38. +47 −0 3.0/modules/carousel/views/carousel_popular.html.php
  39. +49 −0 3.0/modules/carousel/views/carousel_random.html.php
  40. +48 −0 3.0/modules/carousel/views/carousel_recent.html.php
@@ -0,0 +1,28 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+* Gallery - a web based photo album viewer and editor
+* Copyright (C) 2000-2009 Bharat Mediratta
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or (at
+* your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+class About_Controller extends Controller {
+ public function index() {
+ $template = new Theme_View("page.html", "other", "About");
+ $template->css("about.css");
+ $template->page_title = t("Gallery :: About");
+ $template->content = new View("about.html");
+ print $template;
+ }
+}
@@ -0,0 +1,61 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Admin_About_Controller extends Admin_Controller {
+ public function index() {
+ print $this->_get_view();
+ }
+
+ public function handler() {
+ access::verify_csrf();
+
+ $form = $this->_get_form();
+ if ($form->validate()) {
+ module::set_var(
+ "about", "code", $form->about->about_code->value);
+ module::set_var(
+ "about", "title", $form->about->about_title->value);
+ module::set_var (
+ "about", "hidden", $form->about->about_hidden->value);
+ message::success(t("Your settings have been saved."));
+ url::redirect("admin/about");
+ }
+
+ print $this->_get_view($form);
+ }
+
+ private function _get_view($form=null) {
+ $v = new Admin_View("admin.html");
+ $v->content = new View("admin_about.html");
+ $v->content->form = empty($form) ? $this->_get_form() : $form;
+ return $v;
+ }
+
+ private function _get_form() {
+ $form = new Forge("admin/about/handler", "", "post", array("id" => "g-admin-form"));
+ $group = $form->group("about");
+ $group->input("about_title")->label(t('Enter the headline.'))->value(module::get_var("about", "title"));
+ $group->textarea("about_code")->label(t('Enter the standard HTML code you want on the page.'))->value(module::get_var("about", "code"));
+ $group->checkbox("about_hidden")->label(t("Hide link"))
+ ->checked(module::get_var("about", "hidden", false) == 1);
+ $group->submit("submit")->value(t("Save"));
+
+ return $form;
+ }
+}
@@ -0,0 +1,2 @@
+table.about { text-align: center; width:500px; }
+table.about caption { font-size: 1.5em; padding: 0.2em; }
@@ -0,0 +1,39 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class about_block_Core {
+ static function get_site_list() {
+ return array("about" => t("About page"));
+ }
+
+ static function get($block_id, $theme) {
+ $block = "";
+ switch ($block_id) {
+ case "about":
+ if ($theme->item()) {
+ $block = new Block();
+ $block->css_id = "g-metadata";
+ $block->title = module::get_var("about", "title");
+ $block->content = new View("about_block.html");
+ }
+ break;
+ }
+ return $block;
+ }
+}
@@ -0,0 +1,37 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class about_event_Core {
+ static function admin_menu($menu, $theme) {
+ $menu->get("settings_menu")
+ ->append(Menu::factory("link")
+ ->id("about_menu")
+ ->label(t("About page"))
+ ->url(url::site("admin/about")));
+ }
+
+ static function site_menu($menu, $theme) {
+ if (module::get_var("about", "hidden") != true) {
+ $menu->add_after("home", Menu::factory("link")
+ ->id("about")
+ ->label(t("About"))
+ ->url(url::site("about/")));
+ }
+ }
+}
@@ -0,0 +1,26 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class about_installer {
+ static function deactivate() {
+ module::clear_var("about", "title");
+ module::clear_var("about", "code");
+ module::clear_var("about", "hidden");
+ }
+}
@@ -0,0 +1,6 @@
+name = "About"
+description = "About page and detail."
+author_name = "floridave"
+author_url = "http://codex.gallery2.org/User:Floridave"
+info_url = "http://codex.gallery2.org/Gallery3:Modules:about"
+discuss_url = "http://gallery.menalto.com/forum_module_about"
@@ -0,0 +1,3 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<h1><?= module::get_var("about", "title"); ?></h1>
+<?= module::get_var("about", "code"); ?>
@@ -0,0 +1,2 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<?= module::get_var("about", "code"); ?>
@@ -0,0 +1,5 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<div id="g-admin-code-block">
+ <h2><?= t("About Page Administration") ?></h2>
+ <?= $form ?>
+</div>
@@ -0,0 +1,29 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+/**
+ * PHP Mail Configuration parameters
+ * from => email address that appears as the from address
+ * line-length => word wrap length (PHP documentations suggest no larger tha 70 characters
+ * reply-to => what goes into the reply to header
+ */
+$config["ranges"] = array(
+ "Addthis1" => array("low" => "65.249.152.0", "high" => "65.249.159.255"),
+ "Addthis2" => array("low" => "208.122.55.0", "high" => "208.122.55.255")
+);
@@ -0,0 +1,123 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2009 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Addthis_Controller extends Controller {
+ public function print_photo($id) {
+ access::verify_csrf();
+ $item = ORM::factory("item", $id);
+ access::required("view", $item);
+
+ if (access::group_can(identity::everybody(), "view_full", $item)) {
+ $full_url = $item->file_url(true);
+ $thumb_url = $item->thumb_url(true);
+ } else {
+ $proxy = ORM::factory("addthis_proxy");
+ $proxy->uuid = md5(rand());
+ $proxy->item_id = $item->id;
+ $proxy->save();
+ $full_url = url::abs_site("addthis/print_proxy/full/$proxy->uuid");
+ $thumb_url = url::abs_site("addthis/print_proxy/thumb/$proxy->uuid");
+ }
+
+ $v = new View("addthis_form.html");
+ $v->order_parms = array(
+ "addthis_api_version" => "100",
+ "company_id" => module::get_var("addthis", "company_id"),
+ "event_id" => module::get_var("addthis", "event_id"),
+ "cmd" => "addimg",
+ "partner_code" => "69",
+ "return_url" => url::abs_site("addthis/close_window"),
+ "num_images" => "1",
+ "image_1" => $full_url,
+ "thumb_1" => $thumb_url,
+ "image_height_1" => $item->height,
+ "image_width_1" => $item->width,
+ "thumb_height_1" => $item->thumb_height,
+ "thumb_width_1" => $item->thumb_width,
+ "title_1" => html::purify($item->title));
+
+ print $v;
+ }
+
+ public function print_proxy($type, $id) {
+ // If its a request for the full size then make sure we are coming from an
+ // authorized address
+ if ($type == "full") {
+ $remote_addr = ip2long($this->input->server("REMOTE_ADDR"));
+ if ($remote_addr === false) {
+ Kohana::show_404();
+ }
+ $config = Kohana::config("addthis");
+
+ $authorized = false;
+ foreach ($config["ranges"] as $ip_range) {
+ $low = ip2long($ip_range["low"]);
+ $high = ip2long($ip_range["high"]);
+ $authorized = $low !== false && $high !== false &&
+ $low <= $remote_addr && $remote_addr <= $high;
+ if ($authorized) {
+ break;
+ }
+ }
+ if (!$authorized) {
+ Kohana::show_404();
+ }
+ }
+
+ $proxy = ORM::factory("addthis_proxy", array("uuid" => $id));
+ if (!$proxy->loaded || !$proxy->item->loaded) {
+ Kohana::show_404();
+ }
+
+ $file = $type == "full" ? $proxy->item->file_path() : $proxy->item->thumb_path();
+ if (!file_exists($file)) {
+ kohana::show_404();
+ }
+
+ // We don't need to save the session for this request
+ Session::abort_save();
+
+ if (!TEST_MODE) {
+ // Dump out the image
+ header("Content-Type: $proxy->item->mime_type");
+ Kohana::close_buffers(false);
+ $fd = fopen($file, "rb");
+ fpassthru($fd);
+ fclose($fd);
+
+ // If the request was for the image and not the thumb, then delete the proxy.
+ if ($type == "full") {
+ $proxy->delete();
+ }
+ }
+
+ $this->_clean_expired();
+ }
+
+ public function close_window() {
+ print "<script type=\"text/javascript\">window.close();</script>";
+ }
+
+ private function _clean_expired() {
+ Database::instance()->query(
+ "DELETE FROM {addthis_proxies} " .
+ "WHERE request_date <= (CURDATE() - INTERVAL 10 DAY) " .
+ "LIMIT 20");
+ }
+}
Oops, something went wrong.

0 comments on commit 4437d22

Please sign in to comment.