_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->general->reset_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");
}
// save the new inputs
module::set_var("tag_cloud_html5", "show_wholecloud_link", ($form->general->show_wholecloud_link->value == 1));
module::set_var("tag_cloud_html5", "show_add_tag_form", ($form->general->show_add_tag_form->value == 1));
module::set_var("tag_cloud_html5", "show_wholecloud_list", ($form->general->show_wholecloud_list->value == 1));
foreach ($cfg['groups'] as $groupname => $grouptext) {
module::set_var("tag_cloud_html5", "maxtags".$groupname, $form->{"size".$groupname}->{"maxtags".$groupname}->value);
module::set_var("tag_cloud_html5", "width".$groupname, $form->{"size".$groupname}->{"width".$groupname}->value);
module::set_var("tag_cloud_html5", "height".$groupname, $form->{"size".$groupname}->{"height".$groupname}->value);
$optionsarray = array();
// group size
$optionsarray['shape'] = $form->{"size".$groupname}->{"shape".$groupname}->value;
$optionsarray['zoom'] = $form->{"size".$groupname}->{"zoom".$groupname}->value;
$optionsarray['stretchX'] = $form->{"size".$groupname}->{"stretchX".$groupname}->value;
$optionsarray['stretchY'] = $form->{"size".$groupname}->{"stretchY".$groupname}->value;
// group motion
$optionsarray['maxSpeed'] = $form->{"motion".$groupname}->{"maxSpeed".$groupname}->value;
$optionsarray['minSpeed'] = $form->{"motion".$groupname}->{"minSpeed".$groupname}->value;
$optionsarray['deadZone'] = $form->{"motion".$groupname}->{"deadZone".$groupname}->value;
$optionsarray['decel'] = $form->{"motion".$groupname}->{"decel".$groupname}->value;
$optionsarray['initial'] = array($form->{"motion".$groupname}->{"initialX".$groupname}->value, $form->{"motion".$groupname}->{"initialY".$groupname}->value);
$optionsarray['maxInputZone'] = $form->{"motion".$groupname}->{"maxInputZone".$groupname}->value;
// group select
$optionsarray['outlineMethod'] = $form->{"select".$groupname}->{"outlineMethod".$groupname}->value;
$optionsarray['outlineOffset'] = $form->{"select".$groupname}->{"outlineOffset".$groupname}->value;
$optionsarray['outlineColour'] = $form->{"select".$groupname}->{"outlineColour".$groupname}->value;
$optionsarray['frontSelect'] = ($form->{"select".$groupname}->{"frontSelect".$groupname}->value == 1);
// group appearance
$optionsarray['textHeight'] = $form->{"appearance".$groupname}->{"textHeight".$groupname}->value;
$optionsarray['textColour'] = $form->{"appearance".$groupname}->{"textColour".$groupname}->value;
$optionsarray['textFont'] = $form->{"appearance".$groupname}->{"textFont".$groupname}->value;
$optionsarray['depth'] = $form->{"appearance".$groupname}->{"depth".$groupname}->value;
// options that are not explicitly defined in admin menu
$optionsarray['wheelZoom'] = false; // otherwise scrolling through the page screws everything up (was a problem in v1)
$optionsarray['initialDecel'] = true; // this was an option in v4, but it's sorta useless - use minSpeed for a related but better effect
$optionsarray['physModel'] = true; // this is the big enhancement for v5, and is a major modification that I did to TagCanvas
switch ($optionsarray['shape']) {
case "hcylinder":
// keep it horizontal - lock x-axis rotation
$optionsarray['lock'] = "x";
break;
case "vcylinder":
// keep it vertical - lock y-axis rotation
$optionsarray['lock'] = "y";
break;
default:
// do not lock either axis
$optionsarray['lock'] = "";
}
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");
}
// not valid - print screen from existing form
$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"=>t("Sidebar"), "_wholecloud"=>t("Whole cloud"));
// this defines the separator that's used between the group name and the attribute, and is *not* put through t().
$cfg['sep'] = " : ";
// this is used in the labels of the width/height parameters
$cfg['size'] = array("_sidebar"=>t("as fraction of sidebar width, e.g. 'g-block-content' class"), "_wholecloud"=>t("as fraction of browser window height"));
return $cfg;
}
private function _print_screen($form) {
// this part is a bit of a hack, but Forge doesn't seem to allow set_attr() for groups.
$form = $form->render();
$form = preg_replace("/