new module: addthis was not on GIT before
This commit is contained in:
parent
f0a49860c0
commit
ca9b69cfd7
29
3.0/modules/addthis/config/addthis.php
Normal file
29
3.0/modules/addthis/config/addthis.php
Normal file
@ -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")
|
||||||
|
);
|
123
3.0/modules/addthis/controllers/addthis.php
Normal file
123
3.0/modules/addthis/controllers/addthis.php
Normal file
@ -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");
|
||||||
|
}
|
||||||
|
}
|
26
3.0/modules/addthis/controllers/admin_addthis.php
Normal file
26
3.0/modules/addthis/controllers/admin_addthis.php
Normal file
@ -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 Admin_Addthis_Controller extends Admin_Controller {
|
||||||
|
public function index() {
|
||||||
|
$v = new Admin_View("admin.html");
|
||||||
|
$v->content = new View("admin_addthis.html");
|
||||||
|
print $v;
|
||||||
|
}
|
||||||
|
}
|
3
3.0/modules/addthis/css/addthis_menu.css
Normal file
3
3.0/modules/addthis/css/addthis_menu.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#g-view-menu #g-addthis-link {
|
||||||
|
background-image: url('../images/addthis_logo.png');
|
||||||
|
}
|
48
3.0/modules/addthis/helpers/addthis_event.php
Normal file
48
3.0/modules/addthis/helpers/addthis_event.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?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_event_Core {
|
||||||
|
static function admin_menu($menu, $theme) {
|
||||||
|
$menu->get("settings_menu")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->id("addthis_menu")
|
||||||
|
->label(t("AddThis"))
|
||||||
|
->url(url::site("admin/addthis")));
|
||||||
|
}
|
||||||
|
|
||||||
|
static function photo_menu($menu, $theme) {
|
||||||
|
$item = $theme->item();
|
||||||
|
$menu->append(Menu::factory("link")
|
||||||
|
->id("addthis")
|
||||||
|
->label(t("Bookmark and Share: $item->title"))
|
||||||
|
->url("")
|
||||||
|
->css_id("g-addthis-link")
|
||||||
|
->css_class("addthis_button"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static function album_menu($menu, $theme) {
|
||||||
|
$item = $theme->item();
|
||||||
|
$menu->append(Menu::factory("link")
|
||||||
|
->id("addthis")
|
||||||
|
->label(t("Bookmark and Share: $item->title"))
|
||||||
|
->url("")
|
||||||
|
->css_id("g-addthis-link")
|
||||||
|
->css_class("addthis_button"));
|
||||||
|
}
|
||||||
|
}
|
45
3.0/modules/addthis/helpers/addthis_installer.php
Normal file
45
3.0/modules/addthis/helpers/addthis_installer.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?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_installer {
|
||||||
|
static function install() {
|
||||||
|
Database::instance()
|
||||||
|
->query("CREATE TABLE {addthis_proxies} (
|
||||||
|
`id` int(9) NOT NULL AUTO_INCREMENT,
|
||||||
|
`uuid` char(32) NOT NULL,
|
||||||
|
`request_date` TIMESTAMP NOT NULL DEFAULT current_timestamp,
|
||||||
|
`item_id` int(9) NOT NULL,
|
||||||
|
PRIMARY KEY (`id`))
|
||||||
|
DEFAULT CHARSET=utf8;");
|
||||||
|
|
||||||
|
module::set_var("addthis", "username", "");
|
||||||
|
module::set_version("addthis", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function upgrade($version) {
|
||||||
|
if ($version == 1) {
|
||||||
|
module::set_version("addthis", $version = 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static function uninstall() {
|
||||||
|
Database::instance()->query("DROP TABLE IF EXISTS {addthis_proxies}");
|
||||||
|
module::delete("addthis");
|
||||||
|
}
|
||||||
|
}
|
29
3.0/modules/addthis/helpers/addthis_theme.php
Normal file
29
3.0/modules/addthis/helpers/addthis_theme.php
Normal file
@ -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.
|
||||||
|
*/
|
||||||
|
class addthis_theme_Core {
|
||||||
|
static function head($theme) {
|
||||||
|
$addthisuser = module::get_var("addthis", "username");
|
||||||
|
$theme->css("addthis_menu.css");
|
||||||
|
return "<script type=\"text/javascript\" src=\"http://s7.addthis.com/js/250/addthis_widget.js#username=$addthisuser\"></script>\n" .
|
||||||
|
"<script type=\"text/javascript\">" .
|
||||||
|
"var addthis_config = {ui_header_color: \"#ffffff\",ui_header_background: \"#000000\",ui_offset_top: -15,ui_offset_left: 0" .
|
||||||
|
"}</script>";
|
||||||
|
}
|
||||||
|
}
|
BIN
3.0/modules/addthis/images/addthis_logo.png
Normal file
BIN
3.0/modules/addthis/images/addthis_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
22
3.0/modules/addthis/models/addthis_proxy.php
Normal file
22
3.0/modules/addthis/models/addthis_proxy.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?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_Proxy_Model extends ORM {
|
||||||
|
protected $has_one = array("item");
|
||||||
|
}
|
3
3.0/modules/addthis/module.info
Normal file
3
3.0/modules/addthis/module.info
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = "AddThis"
|
||||||
|
description = "Social bookmarking button from: http://www.addthis.com/"
|
||||||
|
version = 1
|
22
3.0/modules/addthis/views/admin_addthis.html.php
Normal file
22
3.0/modules/addthis/views/admin_addthis.html.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<div class="g-block">
|
||||||
|
<img src="<?= url::file("modules/addthis/images/addthis_logo.png") ?>" alt="Add This logo" class="g-right"/>
|
||||||
|
<h1> <?= t("Add This Social bookmarking") ?> </h1>
|
||||||
|
<div class="g-block-content">
|
||||||
|
<p>
|
||||||
|
<?= t("A collection of all the services and destinations available through AddThis. Some are for sharing and bookmarking, others are 'utilities' like printing and translation.<br/>
|
||||||
|
AddThis uses services to provide an intelligent, optimized sharing menu that is designed to offer the right options at the right time and maximize distribution of your content - everywhere.") ?>
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li class="g-module-status g-success">
|
||||||
|
<?= t("You're ready to share your content!") ?>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
<?= t("You don't need an account with Add This, but if you <a href=\"%signup_url\">register with Add This</a> and enter your addthis username in the <a href=\"%advanced_settings_url\">Advanced Settings</a> page you can get Analytics. Example data below.",
|
||||||
|
array("signup_url" => "http://www.addthis.com/register",
|
||||||
|
"advanced_settings_url" => html::mark_clean(url::site("admin/advanced_settings")))) ?>
|
||||||
|
</p>
|
||||||
|
<center><img src="http://cache.addthiscdn.com/www/q0039/style/images/dashboard/bkg-myaccount-sample.jpg"></center>
|
||||||
|
</div>
|
||||||
|
</div>
|
Reference in New Issue
Block a user