예제 #1
0
 /**
  * Produce HTML output for all this fieldset and all contained controls
  *
  * @param boolean $forvalidation True if this control should render error information based on validation.
  * @return string HTML that will render this control in the form
  */
 function get($forvalidation = true)
 {
     $theme = $this->get_theme($forvalidation, $this);
     $max = Tags::max_count();
     $tag = $this->tag;
     $theme->class = 'tag_' . $tag->slug;
     $theme->id = $tag->id;
     $theme->weight = $max > 0 ? round($tag->count * 10 / $max) : 0;
     $theme->caption = $tag->tag;
     $theme->count = $tag->count;
     return $theme->fetch('tabcontrol_tag', true);
 }
예제 #2
0
 /**
  * Handles AJAX from /admin/tags
  * Used to delete and rename tags
  */
 public function ajax_tags($handler_vars)
 {
     Utils::check_request_method(array('POST'));
     $wsse = Utils::WSSE($handler_vars['nonce'], $handler_vars['timestamp']);
     if ($handler_vars['digest'] != $wsse['digest']) {
         Session::error(_t('WSSE authentication failed.'));
         echo Session::messages_get(true, array('Format', 'json_messages'));
         return;
     }
     $tag_names = array();
     $action = $this->handler_vars['action'];
     switch ($action) {
         case 'delete':
             foreach ($_POST as $id => $delete) {
                 // skip POST elements which are not tag ids
                 if (preg_match('/^tag_\\d+/', $id) && $delete) {
                     $id = substr($id, 4);
                     $tag = Tags::get_by_id($id);
                     $tag_names[] = $tag->tag;
                     Tags::delete($tag);
                 }
             }
             $msg_status = sprintf(_n('Tag %s has been deleted.', 'Tags %s have been deleted.', count($tag_names)), implode($tag_names, ', '));
             Session::notice($msg_status);
             echo Session::messages_get(true, array('Format', 'json_messages'));
             break;
         case 'rename':
             if (isset($this->handler_vars['master'])) {
                 $theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', TRUE));
                 $this->theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
                 $master = $this->handler_vars['master'];
                 $tag_names = array();
                 foreach ($_POST as $id => $rename) {
                     // skip POST elements which are not tag ids
                     if (preg_match('/^tag_\\d+/', $id) && $rename) {
                         $id = substr($id, 4);
                         $tag = Tags::get_by_id($id);
                         $tag_names[] = $tag->tag;
                     }
                 }
                 Tags::rename($master, $tag_names);
                 $msg_status = sprintf(_n('Tag %1$s has been renamed to %2$s.', 'Tags %1$s have been renamed to %2$s.', count($tag_names)), implode($tag_names, ', '), $master);
                 Session::notice($msg_status);
                 $this->theme->tags = Tags::get();
                 $this->theme->max = Tags::max_count();
                 echo json_encode(array('msg' => Session::messages_get(true, 'array'), 'tags' => $this->theme->fetch('tag_collection')));
             }
             break;
     }
 }
예제 #3
0
 private function build_cloud()
 {
     $tags = Tags::get();
     $max = Tags::max_count();
     $hide = $this->get_hide_tag_list();
     $this->step = $max / Options::get('fluffytag__steps');
     $this->prefix = explode(',', Options::get('fluffytag__prefix'));
     //$tags = array_filter($tags, create_function( '$a' 'return $a->slug == ' );
     $tags = array_filter($tags, array($this, 'add_count'));
     //print_r( $tags );
     return $tags;
 }