1
0

Tag_Cloud_HTML5 Version 4 - first commit to github.

This commit is contained in:
shadlaws 2012-06-02 14:23:23 +02:00
parent 546d9fa018
commit d87e8432cd
14 changed files with 791 additions and 0 deletions

View File

@ -0,0 +1,254 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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_Tag_Cloud_Html5_Controller extends Admin_Controller {
public function index() {
// print screen from new form
$form = $this->_get_admin_form();
$this->_print_screen($form);
}
public function edit() {
access::verify_csrf();
$cfg = $this->_get_config();
$form = $this->_get_admin_form();
if ($form->validate()) {
if ($form->options_general->load_defaults->value) {
// reset all to defaults, redirect with message
module::install("tag_cloud_html5");
message::success(t("Tag cloud options reset successfully"));
url::redirect("admin/tag_cloud_html5");
} else {
$valid = true;
// run checks on various inputs
$options_general = $form->options_general;
if ($options_general->height_sidebar->value < 0) {
$form->options_general->height_sidebar->add_error("not_valid", 1);
$valid = false;
}
foreach ($cfg['groups'] as $groupname => $grouptext) {
${"options".$groupname} = $form->{"options".$groupname};
if ($options_general->{"maxtags".$groupname}->value < 0) {
$form->options_general->{"maxtags".$groupname}->add_error("not_valid", 1);
$valid = false;
}
if (${"options".$groupname}->{"maxSpeed".$groupname}->value < 0) {
$form->{"options".$groupname}->{"maxSpeed".$groupname}->add_error("not_valid", 1);
$valid = false;
}
if ((${"options".$groupname}->{"initialX".$groupname}->value < -1) || (${"options".$groupname}->{"initialX".$groupname}->value > 1)) {
$form->{"options".$groupname}->{"initialX".$groupname}->add_error("not_valid", 1);
$valid = false;
}
if ((${"options".$groupname}->{"initialY".$groupname}->value < -1) || (${"options".$groupname}->{"initialY".$groupname}->value > 1)) {
$form->{"options".$groupname}->{"initialY".$groupname}->add_error("not_valid", 1);
$valid = false;
}
if ((${"options".$groupname}->{"deadZone".$groupname}->value < 0) || (${"options".$groupname}->{"deadZone".$groupname}->value > 1)) {
$form->{"options".$groupname}->{"deadZone".$groupname}->add_error("not_valid", 1);
$valid = false;
}
if (${"options".$groupname}->{"zoom".$groupname}->value < 0) {
$form->{"options".$groupname}->{"zoom".$groupname}->add_error("not_valid", 1);
$valid = false;
}
if ((${"options".$groupname}->{"depth".$groupname}->value < 0) || (${"options".$groupname}->{"depth".$groupname}->value > 1)) {
$form->{"options".$groupname}->{"depth".$groupname}->add_error("not_valid", 1);
$valid = false;
}
if (${"options".$groupname}->{"outlineOffset".$groupname}->value < 0) {
$form->{"options".$groupname}->{"outlineOffset".$groupname}->add_error("not_valid", 1);
$valid = false;
}
if (preg_match("/^#[0-9A-Fa-f]{6}$/", ${"options".$groupname}->{"outlineColour".$groupname}->value) == 0) {
$form->{"options".$groupname}->{"outlineColour".$groupname}->add_error("not_valid", 1);
$valid = false;
}
if ((preg_match("/^#[0-9A-Fa-f]{6}$/", ${"options".$groupname}->{"textColour".$groupname}->value) == 0) && (strcmp(${"options".$groupname}->{"textColour".$groupname}->value, "") != 0) ) {
$form->{"options".$groupname}->{"textColour".$groupname}->add_error("not_valid", 1);
$valid = false;
}
if (${"options".$groupname}->{"textHeight".$groupname}->value < 0) {
$form->{"options".$groupname}->{"textHeight".$groupname}->add_error("not_valid", 1);
$valid = false;
}
}
if ($valid) {
// all inputs passed tests above; save them
module::set_var("tag_cloud_html5", "show_wholecloud_link", ($options_general->show_wholecloud_link->value == 1));
module::set_var("tag_cloud_html5", "show_add_tag_form", ($options_general->show_add_tag_form->value == 1));
module::set_var("tag_cloud_html5", "height_sidebar", $options_general->height_sidebar->value);
module::set_var("tag_cloud_html5", "show_wholecloud_list", ($options_general->show_wholecloud_list->value == 1));
foreach ($cfg['groups'] as $groupname => $grouptext) {
module::set_var("tag_cloud_html5", "maxtags".$groupname, $options_general->{"maxtags".$groupname}->value);
$optionsarray = array();
$optionsarray['maxSpeed'] = ${"options".$groupname}->{"maxSpeed".$groupname}->value;
$optionsarray['deadZone'] = ${"options".$groupname}->{"deadZone".$groupname}->value;
$optionsarray['initial'] = array(${"options".$groupname}->{"initialX".$groupname}->value, ${"options".$groupname}->{"initialY".$groupname}->value);
$optionsarray['initialDecel'] = (${"options".$groupname}->{"initialDecel".$groupname}->value == 1);
$optionsarray['zoom'] = ${"options".$groupname}->{"zoom".$groupname}->value;
$optionsarray['depth'] = ${"options".$groupname}->{"depth".$groupname}->value;
$optionsarray['outlineMethod'] = ${"options".$groupname}->{"outlineMethod".$groupname}->value;
$optionsarray['outlineOffset'] = ${"options".$groupname}->{"outlineOffset".$groupname}->value;
$optionsarray['outlineColour'] = ${"options".$groupname}->{"outlineColour".$groupname}->value;
$optionsarray['textColour'] = ${"options".$groupname}->{"textColour".$groupname}->value;
$optionsarray['textFont'] = ${"options".$groupname}->{"textFont".$groupname}->value;
$optionsarray['textHeight'] = ${"options".$groupname}->{"textHeight".$groupname}->value;
$optionsarray['frontSelect'] = (${"options".$groupname}->{"frontSelect".$groupname}->value == 1);
$optionsarray['wheelZoom'] = false; // note that this is locked - otherwise scrolling through the page screws everything up
module::set_var("tag_cloud_html5", "options".$groupname, json_encode($optionsarray));
}
// all done; redirect with message
message::success(t("Tag cloud options updated successfully"));
url::redirect("admin/tag_cloud_html5");
}
}
}
// print screen from existing form - you wind up here if something wasn't validated
$this->_print_screen($form);
}
private function _get_config() {
// these define the two variable name groups, along with their labels which are always shown with t() for i18n.
$cfg['groups'] = array("_sidebar"=>"Sidebar", "_wholecloud"=>"Whole cloud");
// this defines the separator that's used between the group name and the attribute, and is *not* put through t().
$cfg['sep'] = ": ";
return $cfg;
}
private function _print_screen($form) {
$view = new Admin_View("admin.html");
$view->content = new View("admin_tag_cloud_html5.html");
$view->content->form = $form;
print $view;
}
private function _get_admin_form() {
$cfg = $this->_get_config();
$sep = $cfg['sep'];
// Make the form. This form has three groups: group_general, group_sidebar, and group_wholecloud.
$form = new Forge("admin/tag_cloud_html5/edit", "", "post", array("id" => "g-tag-cloud-html5-admin-form"));
// group_general
$group_general = $form->group("options_general")->label(t("Tag cloud options").$sep.t("General"));
$group_general->checkbox("load_defaults")
->label(t("Reset all to default values"))
->checked(false);
$group_general->checkbox("show_wholecloud_link")
->label(t("Show 'View whole cloud' link in sidebar"))
->checked(module::get_var("tag_cloud_html5", "show_wholecloud_link", null));
$group_general->checkbox("show_add_tag_form")
->label(t("Show 'Add tag to album' form in sidebar (when permitted and applicable)"))
->checked(module::get_var("tag_cloud_html5", "show_add_tag_form", null));
$group_general->input("height_sidebar")
->label(t("Height of sidebar (as fraction of width)"))
->value(round(module::get_var("tag_cloud_html5", "height_sidebar", null),3)) // round or else it gets 6 decimal places...
->error_message("not_valid", t("Height of sidebar must be a 1-5 digit number"))
->rules("required|valid_numeric|length[1,5]");
$group_general->checkbox("show_wholecloud_list")
->label(t("Show tag list under cloud on 'View whole cloud' page"))
->checked(module::get_var("tag_cloud_html5", "show_wholecloud_list", null));
foreach ($cfg['groups'] as $groupname => $grouptext) {
// maxtags - note that this is displayed under group_general!
$maxtags = module::get_var("tag_cloud_html5", "maxtags".$groupname, null);
$group_general->input("maxtags".$groupname)
->label(t($grouptext).$sep.t("max tags shown"))
->value($maxtags)
->error_message("not_valid", t("Max tags must be a 1-4 digit number"))
->rules("required|valid_numeric|length[1,4]");
// group_sidebar and group_wholecloud
$options = json_decode(module::get_var("tag_cloud_html5", "options".$groupname, null),true);
${"group".$groupname} = $form->group("options".$groupname)->label(t("Tag cloud options").$sep.t($grouptext));
${"group".$groupname}->input("maxSpeed".$groupname)
->label(t($grouptext).$sep.t("max speed (typically 0.01-0.20)"))
->value($options['maxSpeed'])
->error_message("not_valid", t("Max speed must be a 1-5 digit number"))
->rules("required|valid_numeric|length[1,5]");
${"group".$groupname}->input("initialX".$groupname)
->label(t($grouptext).$sep.t("initial horizontal speed (between +/-1.0, as fraction of max speed)"))
->value($options['initial'][0])
->error_message("not_valid", t("Initial horizontal speed must be a 1-4 digit number"))
->rules("required|valid_numeric|length[1,4]");
${"group".$groupname}->input("initialY".$groupname)
->label(t($grouptext).$sep.t("initial vertical speed (between +/-1.0, as fraction of max speed)"))
->value($options['initial'][1])
->error_message("not_valid", t("Initial vertical speed must be a 1-4 digit number"))
->rules("required|valid_numeric|length[1,4]");
${"group".$groupname}->checkbox("initialDecel".$groupname)
->label(t($grouptext).$sep.t("initial deceleration (if false, the initial speed is held until a mouseover event)"))
->checked($options['initialDecel']);
${"group".$groupname}->input("deadZone".$groupname)
->label(t($grouptext).$sep.t("dead zone (0.0-1.0, where 0.0 is no dead zone and 1.0 is no active zone)"))
->value($options['deadZone'])
->error_message("not_valid", t("Dead zone must be a 1-4 digit number"))
->rules("required|valid_numeric|length[1,4]");
${"group".$groupname}->input("zoom".$groupname)
->label(t($grouptext).$sep.t("zoom (<1.0 is zoom out, >1.0 is zoom in)"))
->value($options['zoom'])
->error_message("not_valid", t("Zoom must be a 1-4 digit number"))
->rules("required|valid_numeric|length[1,4]");
${"group".$groupname}->input("depth".$groupname)
->label(t($grouptext).$sep.t("depth (0.0-1.0)"))
->value($options['depth'])
->error_message("not_valid", t("Depth must be a 1-4 digit number"))
->rules("required|valid_numeric|length[1,4]");
${"group".$groupname}->dropdown("outlineMethod".$groupname)
->label(t($grouptext).$sep.t("outline method (mouseover event)"))
->options(array("colour"=>t("change text color"),"outline"=>t("add outline around text"),"block"=>t("add block behind text")))
->selected($options['outlineMethod']);
${"group".$groupname}->input("outlineOffset".$groupname)
->label(t($grouptext).$sep.t("outline offset (mouseover region size around text, in pixels)"))
->value($options['outlineOffset'])
->error_message("not_valid", t("Outline offset must be a 1-2 digit number"))
->rules("required|valid_numeric|length[1,2]");
${"group".$groupname}->input("outlineColour".$groupname)
->label(t($grouptext).$sep.t("outline color (mouseover color, as #hhhhhh)"))
->value($options['outlineColour'])
->error_message("not_valid", t("Outline color must be specified as #hhhhhh"))
->rules("required|length[7]");
${"group".$groupname}->input("textColour".$groupname)
->label(t($grouptext).$sep.t("text color (as #hhhhhh, or empty to use theme color)"))
->value($options['textColour'])
->error_message("not_valid", t("Text color must be specified as empty or #hhhhhh"))
->rules("length[0,7]");
${"group".$groupname}->input("textFont".$groupname)
->label(t($grouptext).$sep.t("text font family (empty to use theme font)"))
->value($options['textFont'])
->error_message("not_valid", t("Text font must be empty or a 0-40 character string"))
->rules("length[0,40]");
${"group".$groupname}->input("textHeight".$groupname)
->label(t($grouptext).$sep.t("text height (in pixels)"))
->value($options['textHeight'])
->error_message("not_valid", t("Text height must be a 1-2 digit number"))
->rules("required|valid_numeric|length[1,2]");
${"group".$groupname}->checkbox("frontSelect".$groupname)
->label(t($grouptext).$sep.t("only allow tags in front to be selected"))
->checked($options['frontSelect']);
}
$form->submit("")->value(t("Save"));
return $form;
}
}

View File

@ -0,0 +1,44 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2012 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 Tag_Cloud_Controller extends Controller {
public function index() {
// Require view permission for the root album for security purposes.
$album = ORM::factory("item", 1);
access::required("view", $album);
// Get settings
$options = module::get_var("tag_cloud_html5", "options_wholecloud", null);
$maxtags = module::get_var("tag_cloud_html5", "maxtags_wholecloud", null);
$options = json_decode($options, true);
$options['hideTags'] = !module::get_var("tag_cloud_html5", "show_wholecloud_list", true);
$options = json_encode($options);
// Set up and display the actual page.
$template = new Theme_View("page.html", "other", "Tag cloud");
$template->content = new View("tag_cloud_html5_page.html");
$template->content->title = t("Tag cloud");
$template->content->cloud = tag::cloud($maxtags);
$template->content->options = $options;
// Display the page.
print $template;
}
}

View File

@ -0,0 +1,30 @@
#g-content fieldset li {
display: block;
clear: both;
height: 24px;
}
#g-content fieldset input {
display: inline;
float: left;
height: 18px;
margin-right: 0.8em;
width: 250px;
}
#g-content fieldset select {
display: inline;
float: left;
height: 24px;
margin-right: 0.8em;
width: 256px;
}
#g-content fieldset label {
display: inline;
line-height: 24px;
}
#g-content fieldset label input.checkbox {
float: left;
height: 24px;
margin-right: 0.8em;
width: 20px;
margin-left: 236px;
}

View File

@ -0,0 +1,106 @@
/* Tag cloud - sidebar ~~~~~~~~~~~~~~~~~~~~~~~ */
/* comment out this first block to make the inline tags appear if the cloud doesn't load */
#g-tag-cloud-html5-tags {
display: none;
}
#g-tag-cloud-html5-tags ul {
text-align: justify;
}
#g-tag-cloud-html5-tags ul li {
display: inline;
text-align: justify;
}
#g-tag-cloud-html5-tags ul li a {
text-decoration: none;
}
#g-tag-cloud-html5-tags ul li span {
display: none;
}
#g-tag-cloud-html5-page ul li a:hover {
text-decoration: underline;
}
/* Tag cloud - whole cloud page ~~~~~~~~~~~~~~~~~~~~~~~ */
#g-tag-cloud-html5-page-canvas {
display: block;
margin: 0 auto;
}
#g-tag-cloud-html5-page-tags ul {
font-size: 1.2em;
text-align: justify;
}
#g-tag-cloud-html5-page-tags ul li {
display: inline;
line-height: 1.5em;
text-align: justify;
}
#g-tag-cloud-html5-page-tags ul li a {
text-decoration: none;
}
#g-tag-cloud-html5-page-tags ul li span {
display: none;
}
#g-tag-cloud-html5-page-tags ul li.size0 a {
color: #9cf;
font-size: 70%;
font-weight: 100;
}
#g-tag-cloud-html5-page-tags ul li.size1 a {
color: #9cf;
font-size: 80%;
font-weight: 100;
}
#g-tag-cloud-html5-page-tags ul li.size2 a {
color: #69f;
font-size: 90%;
font-weight: 300;
}
#g-tag-cloud-html5-page-tags ul li.size3 a {
color: #69c;
font-size: 100%;
font-weight: 500;
}
#g-tag-cloud-html5-page-tags ul li.size4 a {
color: #369;
font-size: 110%;
font-weight: 700;
}
#g-tag-cloud-html5-page-tags ul li.size5 a {
color: #0e2b52;
font-size: 120%;
font-weight: 900;
}
#g-tag-cloud-html5-page-tags ul li.size6 a {
color: #0e2b52;
font-size: 130%;
font-weight: 900;
}
#g-tag-cloud-html5-page-tags ul li.size7 a {
color: #0e2b52;
font-size: 140%;
font-weight: 900;
}
#g-tag-cloud-html5-page-tags ul li a:hover {
color: #f30;
text-decoration: underline;
}

View File

@ -0,0 +1,65 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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 tag_cloud_html5_block {
static function get_site_list() {
return array(
"tag_cloud_html5_site" => (t("Tag cloud")." HTML5"));
}
static function get($block_id, $theme) {
$block = "";
switch ($block_id) {
case "tag_cloud_html5_site":
// load settings
$options = module::get_var("tag_cloud_html5", "options_sidebar", null);
$maxtags = module::get_var("tag_cloud_html5", "maxtags_sidebar", null);
$showlink = module::get_var("tag_cloud_html5", "show_wholecloud_link", null);
$showaddtag = module::get_var("tag_cloud_html5", "show_add_tag_form", null);
$height = module::get_var("tag_cloud_html5", "height_sidebar", null);
// make the block
$block = new Block();
$block->css_id = "g-tag";
$block->title = t("Tag cloud");
$block->content = new View("tag_cloud_html5_block.html");
$block->content->cloud = tag::cloud($maxtags);
$block->content->options = $options;
$block->content->height = $height;
// add the 'View whole cloud' link if needed
if ($showlink) {
$block->content->wholecloud_link = "<a href=".url::site("tag_cloud/").">".t("View whole cloud")."</a>";
} else {
$block->content->wholecloud_link = "";
}
// add the 'Add tag' form if needed
if ($theme->item() && $theme->page_subtype() != "tag" && access::can("edit", $theme->item()) && $showaddtag) {
$controller = new Tags_Controller();
$block->content->form = tag::get_add_form($theme->item());
} else {
$block->content->form = "";
}
break;
}
return $block;
}
}

View File

@ -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-2010 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 tag_cloud_html5_event_Core {
static function admin_menu($menu, $theme) {
$menu->get("settings_menu")
->append(Menu::factory("link")
->id("tag_cloud_html5")
->label(t("Tag cloud")." HTML5")
->url(url::site("admin/tag_cloud_html5")));
}
}

View File

@ -0,0 +1,78 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2012 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 tag_cloud_html5_installer {
static function install() {
// clear and reset default values. this is also called in the admin menu for
// 'reset all to default values' and if the upgrader sees variables missing.
module::clear_all_vars("tag_cloud_html5");
module::set_var("tag_cloud_html5", "show_wholecloud_link", true);
module::set_var("tag_cloud_html5", "show_add_tag_form", true);
module::set_var("tag_cloud_html5", "show_wholecloud_list", true);
module::set_var("tag_cloud_html5", "height_sidebar", 0.8);
module::set_var("tag_cloud_html5", "maxtags_sidebar", 30);
module::set_var("tag_cloud_html5", "maxtags_wholecloud", 500);
module::set_var("tag_cloud_html5", "options_sidebar", json_encode(array(
"maxSpeed" => 0.05,
"deadZone" => 0.25,
"initial" => array(0.8,-0.3),
"initialDecel" => true,
"zoom" => 1.25,
"depth" => 0.5,
"outlineMethod" => "colour",
"outlineOffset" => 8,
"outlineColour" => "#eeeeee",
"textColour" => "",
"textFont" => "",
"textHeight" => 12,
"frontSelect" => true,
"wheelZoom" => false
)));
module::set_var("tag_cloud_html5", "options_wholecloud", json_encode(array(
"maxSpeed" => 0.05,
"deadZone" => 0.25,
"initial" => array(0.8,-0.3),
"initialDecel" => true,
"zoom" => 1.25,
"depth" => 0.5,
"outlineMethod" => "colour",
"outlineOffset" => 8,
"outlineColour" => "#eeeeee",
"textColour" => "",
"textFont" => "",
"textHeight" => 13,
"frontSelect" => true,
"wheelZoom" => false
)));
module::set_version("tag_cloud_html5", 4);
}
static function upgrade() {
if (is_null(module::get_var("tag_cloud_html5", "options_sidebar")) ||
is_null(module::get_var("tag_cloud_html5", "options_wholecloud")) ||
(module::get_version("tag_cloud_html5") < 4) ) {
module::install("tag_cloud_html5");
}
}
static function uninstall() {
module::clear_all_vars("tag_cloud_html5");
}
}

View File

@ -0,0 +1,25 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 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 tag_cloud_html5_theme_Core {
static function head($theme) {
$theme->script("jquery.tagcanvas.mod.min.js");
$theme->css("tag_cloud_html5.css");
}
}

View File

@ -0,0 +1,35 @@
// Copyright 2006 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
document.createElement("canvas").getContext||(function(){var s=Math,j=s.round,F=s.sin,G=s.cos,V=s.abs,W=s.sqrt,k=10,v=k/2;function X(){return this.context_||(this.context_=new H(this))}var L=Array.prototype.slice;function Y(b,a){var c=L.call(arguments,2);return function(){return b.apply(a,c.concat(L.call(arguments)))}}var M={init:function(b){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var a=b||document;a.createElement("canvas");a.attachEvent("onreadystatechange",Y(this.init_,this,a))}},init_:function(b){b.namespaces.g_vml_||
b.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML");b.namespaces.g_o_||b.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML");if(!b.styleSheets.ex_canvas_){var a=b.createStyleSheet();a.owningElement.id="ex_canvas_";a.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}g_o_\\:*{behavior:url(#default#VML)}"}var c=b.getElementsByTagName("canvas"),d=0;for(;d<c.length;d++)this.initElement(c[d])},
initElement:function(b){if(!b.getContext){b.getContext=X;b.innerHTML="";b.attachEvent("onpropertychange",Z);b.attachEvent("onresize",$);var a=b.attributes;if(a.width&&a.width.specified)b.style.width=a.width.nodeValue+"px";else b.width=b.clientWidth;if(a.height&&a.height.specified)b.style.height=a.height.nodeValue+"px";else b.height=b.clientHeight}return b}};function Z(b){var a=b.srcElement;switch(b.propertyName){case "width":a.style.width=a.attributes.width.nodeValue+"px";a.getContext().clearRect();
break;case "height":a.style.height=a.attributes.height.nodeValue+"px";a.getContext().clearRect();break}}function $(b){var a=b.srcElement;if(a.firstChild){a.firstChild.style.width=a.clientWidth+"px";a.firstChild.style.height=a.clientHeight+"px"}}M.init();var N=[],B=0;for(;B<16;B++){var C=0;for(;C<16;C++)N[B*16+C]=B.toString(16)+C.toString(16)}function I(){return[[1,0,0],[0,1,0],[0,0,1]]}function y(b,a){var c=I(),d=0;for(;d<3;d++){var f=0;for(;f<3;f++){var h=0,g=0;for(;g<3;g++)h+=b[d][g]*a[g][f];c[d][f]=
h}}return c}function O(b,a){a.fillStyle=b.fillStyle;a.lineCap=b.lineCap;a.lineJoin=b.lineJoin;a.lineWidth=b.lineWidth;a.miterLimit=b.miterLimit;a.shadowBlur=b.shadowBlur;a.shadowColor=b.shadowColor;a.shadowOffsetX=b.shadowOffsetX;a.shadowOffsetY=b.shadowOffsetY;a.strokeStyle=b.strokeStyle;a.globalAlpha=b.globalAlpha;a.arcScaleX_=b.arcScaleX_;a.arcScaleY_=b.arcScaleY_;a.lineScale_=b.lineScale_}function P(b){var a,c=1;b=String(b);if(b.substring(0,3)=="rgb"){var d=b.indexOf("(",3),f=b.indexOf(")",d+
1),h=b.substring(d+1,f).split(",");a="#";var g=0;for(;g<3;g++)a+=N[Number(h[g])];if(h.length==4&&b.substr(3,1)=="a")c=h[3]}else a=b;return{color:a,alpha:c}}function aa(b){switch(b){case "butt":return"flat";case "round":return"round";case "square":default:return"square"}}function H(b){this.m_=I();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.fillStyle=this.strokeStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=k*1;this.globalAlpha=1;this.canvas=b;
var a=b.ownerDocument.createElement("div");a.style.width=b.clientWidth+"px";a.style.height=b.clientHeight+"px";a.style.overflow="hidden";a.style.position="absolute";b.appendChild(a);this.element_=a;this.lineScale_=this.arcScaleY_=this.arcScaleX_=1}var i=H.prototype;i.clearRect=function(){this.element_.innerHTML=""};i.beginPath=function(){this.currentPath_=[]};i.moveTo=function(b,a){var c=this.getCoords_(b,a);this.currentPath_.push({type:"moveTo",x:c.x,y:c.y});this.currentX_=c.x;this.currentY_=c.y};
i.lineTo=function(b,a){var c=this.getCoords_(b,a);this.currentPath_.push({type:"lineTo",x:c.x,y:c.y});this.currentX_=c.x;this.currentY_=c.y};i.bezierCurveTo=function(b,a,c,d,f,h){var g=this.getCoords_(f,h),l=this.getCoords_(b,a),e=this.getCoords_(c,d);Q(this,l,e,g)};function Q(b,a,c,d){b.currentPath_.push({type:"bezierCurveTo",cp1x:a.x,cp1y:a.y,cp2x:c.x,cp2y:c.y,x:d.x,y:d.y});b.currentX_=d.x;b.currentY_=d.y}i.quadraticCurveTo=function(b,a,c,d){var f=this.getCoords_(b,a),h=this.getCoords_(c,d),g={x:this.currentX_+
0.6666666666666666*(f.x-this.currentX_),y:this.currentY_+0.6666666666666666*(f.y-this.currentY_)};Q(this,g,{x:g.x+(h.x-this.currentX_)/3,y:g.y+(h.y-this.currentY_)/3},h)};i.arc=function(b,a,c,d,f,h){c*=k;var g=h?"at":"wa",l=b+G(d)*c-v,e=a+F(d)*c-v,m=b+G(f)*c-v,r=a+F(f)*c-v;if(l==m&&!h)l+=0.125;var n=this.getCoords_(b,a),o=this.getCoords_(l,e),q=this.getCoords_(m,r);this.currentPath_.push({type:g,x:n.x,y:n.y,radius:c,xStart:o.x,yStart:o.y,xEnd:q.x,yEnd:q.y})};i.rect=function(b,a,c,d){this.moveTo(b,
a);this.lineTo(b+c,a);this.lineTo(b+c,a+d);this.lineTo(b,a+d);this.closePath()};i.strokeRect=function(b,a,c,d){var f=this.currentPath_;this.beginPath();this.moveTo(b,a);this.lineTo(b+c,a);this.lineTo(b+c,a+d);this.lineTo(b,a+d);this.closePath();this.stroke();this.currentPath_=f};i.fillRect=function(b,a,c,d){var f=this.currentPath_;this.beginPath();this.moveTo(b,a);this.lineTo(b+c,a);this.lineTo(b+c,a+d);this.lineTo(b,a+d);this.closePath();this.fill();this.currentPath_=f};i.createLinearGradient=function(b,
a,c,d){var f=new D("gradient");f.x0_=b;f.y0_=a;f.x1_=c;f.y1_=d;return f};i.createRadialGradient=function(b,a,c,d,f,h){var g=new D("gradientradial");g.x0_=b;g.y0_=a;g.r0_=c;g.x1_=d;g.y1_=f;g.r1_=h;return g};i.drawImage=function(b){var a,c,d,f,h,g,l,e,m=b.runtimeStyle.width,r=b.runtimeStyle.height;b.runtimeStyle.width="auto";b.runtimeStyle.height="auto";var n=b.width,o=b.height;b.runtimeStyle.width=m;b.runtimeStyle.height=r;if(arguments.length==3){a=arguments[1];c=arguments[2];h=g=0;l=d=n;e=f=o}else if(arguments.length==
5){a=arguments[1];c=arguments[2];d=arguments[3];f=arguments[4];h=g=0;l=n;e=o}else if(arguments.length==9){h=arguments[1];g=arguments[2];l=arguments[3];e=arguments[4];a=arguments[5];c=arguments[6];d=arguments[7];f=arguments[8]}else throw Error("Invalid number of arguments");var q=this.getCoords_(a,c),t=[];t.push(" <g_vml_:group",' coordsize="',k*10,",",k*10,'"',' coordorigin="0,0"',' style="width:',10,"px;height:",10,"px;position:absolute;");if(this.m_[0][0]!=1||this.m_[0][1]){var E=[];E.push("M11=",
this.m_[0][0],",","M12=",this.m_[1][0],",","M21=",this.m_[0][1],",","M22=",this.m_[1][1],",","Dx=",j(q.x/k),",","Dy=",j(q.y/k),"");var p=q,z=this.getCoords_(a+d,c),w=this.getCoords_(a,c+f),x=this.getCoords_(a+d,c+f);p.x=s.max(p.x,z.x,w.x,x.x);p.y=s.max(p.y,z.y,w.y,x.y);t.push("padding:0 ",j(p.x/k),"px ",j(p.y/k),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",E.join(""),", sizingmethod='clip');")}else t.push("top:",j(q.y/k),"px;left:",j(q.x/k),"px;");t.push(' ">','<g_vml_:image src="',b.src,
'"',' style="width:',k*d,"px;"," height:",k*f,'px;"',' cropleft="',h/n,'"',' croptop="',g/o,'"',' cropright="',(n-h-l)/n,'"',' cropbottom="',(o-g-e)/o,'"'," />","</g_vml_:group>");this.element_.insertAdjacentHTML("BeforeEnd",t.join(""))};i.stroke=function(b){var a=[],c=P(b?this.fillStyle:this.strokeStyle),d=c.color,f=c.alpha*this.globalAlpha;a.push("<g_vml_:shape",' filled="',!!b,'"',' style="position:absolute;width:',10,"px;height:",10,'px;"',' coordorigin="0 0" coordsize="',k*10," ",k*10,'"',' stroked="',
!b,'"',' path="');var h={x:null,y:null},g={x:null,y:null},l=0;for(;l<this.currentPath_.length;l++){var e=this.currentPath_[l];switch(e.type){case "moveTo":a.push(" m ",j(e.x),",",j(e.y));break;case "lineTo":a.push(" l ",j(e.x),",",j(e.y));break;case "close":a.push(" x ");e=null;break;case "bezierCurveTo":a.push(" c ",j(e.cp1x),",",j(e.cp1y),",",j(e.cp2x),",",j(e.cp2y),",",j(e.x),",",j(e.y));break;case "at":case "wa":a.push(" ",e.type," ",j(e.x-this.arcScaleX_*e.radius),",",j(e.y-this.arcScaleY_*e.radius),
" ",j(e.x+this.arcScaleX_*e.radius),",",j(e.y+this.arcScaleY_*e.radius)," ",j(e.xStart),",",j(e.yStart)," ",j(e.xEnd),",",j(e.yEnd));break}if(e){if(h.x==null||e.x<h.x)h.x=e.x;if(g.x==null||e.x>g.x)g.x=e.x;if(h.y==null||e.y<h.y)h.y=e.y;if(g.y==null||e.y>g.y)g.y=e.y}}a.push(' ">');if(b)if(typeof this.fillStyle=="object"){var m=this.fillStyle,r=0,n={x:0,y:0},o=0,q=1;if(m.type_=="gradient"){var t=m.x1_/this.arcScaleX_,E=m.y1_/this.arcScaleY_,p=this.getCoords_(m.x0_/this.arcScaleX_,m.y0_/this.arcScaleY_),
z=this.getCoords_(t,E);r=Math.atan2(z.x-p.x,z.y-p.y)*180/Math.PI;if(r<0)r+=360;if(r<1.0E-6)r=0}else{var p=this.getCoords_(m.x0_,m.y0_),w=g.x-h.x,x=g.y-h.y;n={x:(p.x-h.x)/w,y:(p.y-h.y)/x};w/=this.arcScaleX_*k;x/=this.arcScaleY_*k;var R=s.max(w,x);o=2*m.r0_/R;q=2*m.r1_/R-o}var u=m.colors_;u.sort(function(ba,ca){return ba.offset-ca.offset});var J=u.length,da=u[0].color,ea=u[J-1].color,fa=u[0].alpha*this.globalAlpha,ga=u[J-1].alpha*this.globalAlpha,S=[],l=0;for(;l<J;l++){var T=u[l];S.push(T.offset*q+
o+" "+T.color)}a.push('<g_vml_:fill type="',m.type_,'"',' method="none" focus="100%"',' color="',da,'"',' color2="',ea,'"',' colors="',S.join(","),'"',' opacity="',ga,'"',' g_o_:opacity2="',fa,'"',' angle="',r,'"',' focusposition="',n.x,",",n.y,'" />')}else a.push('<g_vml_:fill color="',d,'" opacity="',f,'" />');else{var K=this.lineScale_*this.lineWidth;if(K<1)f*=K;a.push("<g_vml_:stroke",' opacity="',f,'"',' joinstyle="',this.lineJoin,'"',' miterlimit="',this.miterLimit,'"',' endcap="',aa(this.lineCap),
'"',' weight="',K,'px"',' color="',d,'" />')}a.push("</g_vml_:shape>");this.element_.insertAdjacentHTML("beforeEnd",a.join(""))};i.fill=function(){this.stroke(true)};i.closePath=function(){this.currentPath_.push({type:"close"})};i.getCoords_=function(b,a){var c=this.m_;return{x:k*(b*c[0][0]+a*c[1][0]+c[2][0])-v,y:k*(b*c[0][1]+a*c[1][1]+c[2][1])-v}};i.save=function(){var b={};O(this,b);this.aStack_.push(b);this.mStack_.push(this.m_);this.m_=y(I(),this.m_)};i.restore=function(){O(this.aStack_.pop(),
this);this.m_=this.mStack_.pop()};function ha(b){var a=0;for(;a<3;a++){var c=0;for(;c<2;c++)if(!isFinite(b[a][c])||isNaN(b[a][c]))return false}return true}function A(b,a,c){if(!!ha(a)){b.m_=a;if(c)b.lineScale_=W(V(a[0][0]*a[1][1]-a[0][1]*a[1][0]))}}i.translate=function(b,a){A(this,y([[1,0,0],[0,1,0],[b,a,1]],this.m_),false)};i.rotate=function(b){var a=G(b),c=F(b);A(this,y([[a,c,0],[-c,a,0],[0,0,1]],this.m_),false)};i.scale=function(b,a){this.arcScaleX_*=b;this.arcScaleY_*=a;A(this,y([[b,0,0],[0,a,
0],[0,0,1]],this.m_),true)};i.transform=function(b,a,c,d,f,h){A(this,y([[b,a,0],[c,d,0],[f,h,1]],this.m_),true)};i.setTransform=function(b,a,c,d,f,h){A(this,[[b,a,0],[c,d,0],[f,h,1]],true)};i.clip=function(){};i.arcTo=function(){};i.createPattern=function(){return new U};function D(b){this.type_=b;this.r1_=this.y1_=this.x1_=this.r0_=this.y0_=this.x0_=0;this.colors_=[]}D.prototype.addColorStop=function(b,a){a=P(a);this.colors_.push({offset:b,color:a.color,alpha:a.alpha})};function U(){}G_vmlCanvasManager=
M;CanvasRenderingContext2D=H;CanvasGradient=D;CanvasPattern=U})();

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
name = "Tag Cloud HTML5"
description = "HTML5-compliant tag cloud. Functions as non-Flash replacements for both 'tag_cloud' and 'tag_cloud_page' modules, with some extra features added."
version = 4
author_name = "Shad Laws"
author_url = ""
info_url = "http://codex.gallery2.org/Gallery3:Modules:tag_cloud_html5"
discuss_url = "http://gallery.menalto.com/node/106774"

View File

@ -0,0 +1,16 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<style>
@import "<?= url::file("modules/tag_cloud_html5/css/admin_tag_cloud_html5.css"); ?>";
</style>
<div id="g-tag-cloud-html5-admin">
<h2>
<?= t("Tag cloud HTML5 settings") ?>
</h2>
<p>
<?= t("This module uses TagCanvas, a non-flash, HTML5-compliant jQuery plugin. It also uses <a href=\"http://excanvas.sourceforge.net/\">excanvas</a> to maintain compatibility with pre-9.0 Internet Explorer.") ?>
</p>
<p>
<?= t("More details on the options below are given at TagCanvas's homepage <a href='http://www.goat1000.com/tagcanvas.php'>here</a>.") ?>
</p>
<?= $form ?>
</div>

View File

@ -0,0 +1,38 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<!--[if lt IE 9]><?= $theme->script("excanvas.compiled.js"); ?><![endif]-->
<script type="text/javascript">
$(document).ready(function() {
// set g-tag-cloud-html5-canvas size
$("#g-tag-cloud-html5-canvas").attr({
'width': $("#g-tag-cloud-html5").width(),
'height': $("#g-tag-cloud-html5").width()*<?= $height ?>
});
// start g-tag-cloud-html5-canvas
if(!$('#g-tag-cloud-html5-canvas').tagcanvas(<?= $options ?>,'g-tag-cloud-html5-tags')) {
// something went wrong, hide the canvas container g-tag-cloud-html5
$('#g-tag-cloud-html5').hide();
};
// tag autocomplete for g-add-tag-form
$("#g-add-tag-form input:text").autocomplete(
"<?= url::site("/tags/autocomplete") ?>", {
max: 30,
multiple: true,
multipleSeparator: ',',
cacheLength: 1}
);
});
</script>
<div id="g-tag-cloud-html5">
<canvas id="g-tag-cloud-html5-canvas">
<? echo t('Tag cloud loading...'); ?>
</canvas>
</div>
<div id="g-tag-cloud-html5-tags">
<?= $cloud ?>
</div>
<?= $wholecloud_link ?>
<?= $form ?>

View File

@ -0,0 +1,38 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<!--[if lt IE 9]><?= $theme->script("excanvas.compiled.js"); ?><![endif]-->
<script type="text/javascript">
function redraw() {
// set g-tag-cloud-html5-page-canvas size
$("#g-tag-cloud-html5-page-canvas").attr({
'height': Math.min( $(window).height()*0.75, $("#g-tag-cloud-html5-page").width() ),
'width': Math.min( $(window).height()*0.95, $("#g-tag-cloud-html5-page").width() )
});
// start g-tag-cloud-html5-page-canvas
if(!$('#g-tag-cloud-html5-page-canvas').tagcanvas(<?= $options ?>,'g-tag-cloud-html5-page-tags')) {
// something went wrong, hide the canvas container g-tag-cloud-html5-page
$('#g-tag-cloud-html5-page').hide();
};
};
// resize and redraw the canvas
$(window).resize(redraw);
$(document).ready(redraw);
</script>
<div id="g-tag-cloud-html5-page-header">
<div id="g-tag-cloud-html5-page-buttons">
<?= $theme->dynamic_top() ?>
</div>
<h1><?= html::clean($title) ?></h1>
</div>
<div id="g-tag-cloud-html5-page">
<canvas id="g-tag-cloud-html5-page-canvas">
<? echo t('Tag cloud loading...'); ?>
</canvas>
</div>
<div id="g-tag-cloud-html5-page-tags">
<?= $cloud ?>
</div>
<?= $theme->dynamic_bottom() ?>