Add an administrative screen to the tag cloud module and change the block template to pass those variable to the browser.
This commit is contained in:
parent
79a7bd1aec
commit
f96adbde80
85
modules/tag_cloud/controllers/admin_tag_cloud.php
Normal file
85
modules/tag_cloud/controllers/admin_tag_cloud.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?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_Tag_Cloud_Controller extends Admin_Controller {
|
||||
public function index() {
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_tag_cloud.html");
|
||||
$view->content->form = $this->_get_admin_form();
|
||||
|
||||
print $view;
|
||||
}
|
||||
|
||||
public function edit() {
|
||||
access::verify_csrf();
|
||||
|
||||
$form = $this->_get_admin_form();
|
||||
if ($form->validate()) {
|
||||
$options = $form->tag_cloud_options;
|
||||
$valid = true;
|
||||
if (preg_match("/^0x[0-9A-Fa-f]{6}$/", $options->tagcolor->value) == 0) {
|
||||
$options->tagcolor->add_error("not_valid", 1);
|
||||
$valid = false;
|
||||
}
|
||||
if (preg_match("/^0x[0-9A-Fa-f]{6}$/", $options->background_color->value) == 0) {
|
||||
$options->background_color->add_error("not_valid", 1);
|
||||
$valid = false;
|
||||
}
|
||||
if ($valid) {
|
||||
module::set_var("tag_cloud", "tagcolor", $options->tagcolor->value);
|
||||
module::set_var("tag_cloud", "background_color", $options->background_color->value);
|
||||
module::set_var("tag_cloud", "transparent", $options->transparent->value);
|
||||
module::set_var("tag_cloud", "speed", $options->speed->value);
|
||||
module::set_var("tag_cloud", "distribution", $options->distribution->value);
|
||||
message::success(t("Tag cloud options updated successfully"));
|
||||
url::redirect("admin/tag_cloud");
|
||||
}
|
||||
}
|
||||
|
||||
$view = new Admin_View("admin.html");
|
||||
$view->content = new View("admin_tag_cloud.html");
|
||||
$view->content->form = $form;
|
||||
|
||||
print $view;
|
||||
}
|
||||
|
||||
private function _get_admin_form() {
|
||||
$form = new Forge("admin/tag_cloud/edit", "", "post",
|
||||
array("id" => "gTagCloudAdminForm"));
|
||||
$group = $form->group("tag_cloud_options")->label(t("Tag Cloud Options"));
|
||||
$group->input("tagcolor") ->label(t("Tag color"))
|
||||
->value(module::get_var("tag_cloud", "tagcolor", "0x333333"))
|
||||
->error_message("not_valid", t("The color value must be specified as '0xhhhhhh'"))
|
||||
->rules("required|length[8]");
|
||||
$group->input("background_color")->label(t("Background color"))
|
||||
->value(module::get_var("tag_cloud", "background_color", "0xffffff"))
|
||||
->error_message("not_valid", t("The color value must be specified as '0xhhhhhh'"))
|
||||
->rules("required|length[8]");
|
||||
$group->checkbox("transparent")->label(t("Transparent mode"))
|
||||
->checked(module::get_var("tag_cloud", "transparent", 0) == 1);
|
||||
$group->input("speed")->label(t("Rotation speed"))
|
||||
->value(module::get_var("tag_cloud", "speed", "100"))
|
||||
->rules("required|valid_numeric|length[1,3]");
|
||||
$group->checkbox("distribution")->label(t("Distribute tags evenly"))
|
||||
->checked(module::get_var("tag_cloud", "distribution", 1) == 1);
|
||||
$group->submit("")->value(t("Save"));
|
||||
|
||||
return $form;
|
||||
}
|
||||
}
|
@ -27,11 +27,36 @@ class tag_cloud_block {
|
||||
$block = "";
|
||||
switch ($block_id) {
|
||||
case "tag_cloud_site":
|
||||
$options = array();
|
||||
foreach (array("tagcolor", "background_color", "transparent", "speed", "distribution")
|
||||
as $option) {
|
||||
$value = module::get_var("tag_cloud", $option, null);
|
||||
if (!empty($value)) {
|
||||
switch ($option) {
|
||||
case "tagcolor":
|
||||
$options["tcolor"] = $value;
|
||||
break;
|
||||
case "background_color":
|
||||
$options["bgColor"] = $value;
|
||||
break;
|
||||
case "transparent":
|
||||
$options["wmode"] = "\"transparent\"";
|
||||
break;
|
||||
case "speed":
|
||||
$options["tspeed"] = $value;
|
||||
break;
|
||||
case "distribution":
|
||||
$options["distr"] = "\"true\"";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$block = new Block();
|
||||
$block->css_id = "gTag3D";
|
||||
$block->title = t("Tag Cloud");
|
||||
$block->content = new View("tag_cloud_block.html");
|
||||
$block->content->cloud = tag::cloud(30);
|
||||
$block->content->options = $options;
|
||||
|
||||
if ($theme->item() && $theme->page_type() != "tag" && access::can("edit", $theme->item())) {
|
||||
$controller = new Tags_Controller();
|
||||
|
28
modules/tag_cloud/helpers/tag_cloud_event.php
Normal file
28
modules/tag_cloud/helpers/tag_cloud_event.php
Normal 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-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 tag_cloud_event_Core {
|
||||
static function admin_menu($menu, $theme) {
|
||||
$menu->get("appearance_menu")
|
||||
->append(Menu::factory("link")
|
||||
->id("tag_cloud")
|
||||
->label(t("Tag Cloud"))
|
||||
->url(url::site("admin/tag_cloud")));
|
||||
}
|
||||
}
|
@ -56,7 +56,7 @@
|
||||
"&distr=" + self.options.distr + "&mode=" + self.options.mode +
|
||||
"&tagcloud=" + escape("<tags>" + $(tags).html() + "</tags>");
|
||||
$(object).append("<param name=\"movie\" value=\"" + self.options.movie +"\" />")
|
||||
.append("<param name=\"wmode\" value=\"" + self.options.transparent + "\" />")
|
||||
.append("<param name=\"wmode\" value=\"" + self.options.wmode + "\" />")
|
||||
.append("<param name=\"bgcolor\" value=\"" + self.options.bgColor + "\" />")
|
||||
.append("<param name=\"allowScriptAccess\"value=\"" + self.options.scriptAccess + "\" />")
|
||||
.append("<param name=\"flashvars\" value=\"" + value + "\" />");
|
||||
|
7
modules/tag_cloud/views/admin_tag_cloud.html.php
Normal file
7
modules/tag_cloud/views/admin_tag_cloud.html.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<div id="gTagCloud3DAdmin">
|
||||
<h2>
|
||||
<?= t("Manage Tag Cloud") ?>
|
||||
</h2>
|
||||
<?= $form ?>
|
||||
</div>
|
@ -2,7 +2,10 @@
|
||||
<script>
|
||||
$("document").ready(function() {
|
||||
$("#gTag3D").gallery_tag_cloud({
|
||||
movie: "<?= url::file("modules/tag_cloud/lib/tagcloud.swf") ?>",
|
||||
movie: "<?= url::file("modules/tag_cloud/lib/tagcloud.swf") ?>"
|
||||
<? foreach ($options as $option => $value) : ?>
|
||||
, <?= $option ?> : <?= $value ?>
|
||||
<? endforeach ?>
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user