Exemple #1
0
 public function _index()
 {
     // Far from perfection, but at least require view permission for the root album
     $album = ORM::factory("item", 1);
     access::required("view", $album);
     print tag::cloud(30);
 }
Exemple #2
0
 static function sidebar_blocks($theme)
 {
     $block = new Block();
     $block->css_id = "gTag";
     $block->title = t("Popular Tags");
     $block->content = new View("tag_block.html");
     $block->content->cloud = tag::cloud(30);
     if ($theme->page_type() != "tag" && access::can("edit", $theme->item())) {
         $controller = new Tags_Controller();
         $block->content->form = tag::get_add_form($theme->item());
     } else {
         $block->content->form = "";
     }
     return $block;
 }
 static function get($block_id, $theme)
 {
     $block = "";
     switch ($block_id) {
         case "tag_cloud_site":
             $options = array();
             foreach (array("tagcolor", "background_color", "mouseover", "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 "mouseover":
                             $options["hicolor"] = $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 = "g-tag";
             $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_subtype() != "tag" && access::can("edit", $theme->item())) {
                 $controller = new Tags_Controller();
                 $block->content->form = tag::get_add_form($theme->item());
             } else {
                 $block->content->form = "";
             }
             break;
     }
     return $block;
 }
Exemple #4
0
 public function create($item_id)
 {
     $item = ORM::factory("item", $item_id);
     access::required("view", $item);
     access::required("edit", $item);
     $form = tag::get_add_form($item);
     if ($form->validate()) {
         foreach (explode(",", $form->add_tag->inputs["name"]->value) as $tag_name) {
             $tag_name = trim($tag_name);
             if ($tag_name) {
                 $tag = tag::add($item, $tag_name);
             }
         }
         print json_encode(array("result" => "success", "cloud" => (string) tag::cloud(30)));
     } else {
         print json_encode(array("result" => "error", "form" => (string) $form));
     }
 }
Exemple #5
0
 static function get($block_id, $theme)
 {
     $block = "";
     switch ($block_id) {
         case "tag":
             $block = new Block();
             $block->css_id = "g-tag";
             $block->title = t("Popular tags");
             $block->content = new View("tag_block.html");
             $block->content->cloud = tag::cloud(module::get_var("tag", "tag_cloud_size", 30));
             if ($theme->item() && $theme->page_subtype() != "tag" && access::can("edit", $theme->item())) {
                 $controller = new Tags_Controller();
                 $block->content->form = tag::get_add_form($theme->item());
             } else {
                 $block->content->form = "";
             }
             break;
     }
     return $block;
 }
 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);
             $width = module::get_var("tag_cloud_html5", "width_sidebar", 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->width = $width;
             $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;
 }
Exemple #7
0
 public function _index()
 {
     print tag::cloud(30);
 }
 public function embed()
 {
     /**
      * This is used to embed the tag cloud in other things.  New in version 7.
      *
      * It expects the url to be in the form:
      *   tag_cloud/embed/optionsbase/option1/value1/option2/value2/.../optionN/valueN
      * Where:
      *   optionsbase = "sidebar" or "wholecloud" (takes settings from this config)
      *   optionX = option name (either "maxtags" or any of the TagCanvas parameters - no name verification performed!)
      *   valueX = value of option (no value verification performed here!)
      * Here's how the tag cloud is built:
      * 1. Load "maxtags" and "options" variables for optionbase (as defined in admin menu or admin/advanced variables)
      *    Note: width and height are ignored, and the add tag form, wholecloud link, and inline tags are not shown.
      * 2. Use option/value pairs to override and/or append those loaded above.
      * 3. Build tag cloud, using 100% of the size from its parent.
      * Correspondingly, the optionsbase is required, but the options and values are not.
      */
     // Require view permission for the root album for security purposes.
     $album = ORM::factory("item", 1);
     access::required("view", $album);
     // get the function arguments
     $args = func_get_args();
     // get/check the number of arguments - must be odd
     $countargs = count($args);
     if ($countargs % 2 == 0) {
         return;
     }
     // get/check the first argument - must be sidebar or wholecloud
     $optionsbase = $args[0];
     if (!in_array($optionsbase, array("sidebar", "wholecloud"))) {
         return;
     }
     // get and override/append options/values
     $maxtags = module::get_var("tag_cloud_html5", "maxtags_" . $optionsbase, null);
     $options = module::get_var("tag_cloud_html5", "options_" . $optionsbase, null);
     $options = json_decode($options, true);
     for ($i = 0; $i < ($countargs - 1) / 2; $i++) {
         $option = $args[2 * $i + 1];
         $value = $args[2 * $i + 2];
         if ($option == "maxtags") {
             // assign to maxtags
             $maxtags = $value;
         } elseif (substr($option, -6) == 'Colour') {
             // assign to options with a hash in front
             $options[$option] = '#' . $value;
         } else {
             // assign to options
             $options[$option] = $value;
         }
     }
     $options = json_encode($options);
     // Set up and display the actual page.
     $template = new View("tag_cloud_html5_embed.html");
     $template->cloud = tag::cloud($maxtags);
     $template->options = $options;
     // Display the page.
     print $template;
 }
    ?>
    });
  });
</script>
<div id="g-tag-cloud-page">
  <div id="g-tag-cloud-page-animation" ref="<?php 
    echo url::site("tag_cloud_page");
    ?>
">
    <div id="g-tag-cloud-movie-page">
      <?php 
    echo tag::cloud(ORM::factory("tag")->count_all());
    ?>
    </div>
  </div>
</div>

<?php 
} else {
    ?>
<div id="g-tag-cloud-page">
  <?php 
    echo tag::cloud(ORM::factory("tag")->count_all());
    ?>
</div>
<?php 
}
?>

<?php 
echo $theme->dynamic_bottom();