/** * Handle GET requests for /admin/tags to display the tags. */ public function get_tags() { $this->theme->wsse = Utils::WSSE(); $this->theme->tags = Tags::vocabulary()->get_tree('term_display asc'); $this->theme->max = Tags::vocabulary()->max_count(); $this->theme->min = Tags::vocabulary()->min_count(); $form = new FormUI('tags'); $form->append(FormControlFacet::create('search')->set_property('data-facet-config', array('onsearch' => 'deselect_all(); $("#tag_collection").manager("update", self.data("visualsearch").searchQuery.facets());', 'facetsURL' => URL::get('admin_ajax_facets', array('context' => 'facets', 'page' => 'tags', 'component' => 'facets')), 'valuesURL' => URL::get('admin_ajax_facets', array('context' => 'facets', 'page' => 'tags', 'component' => 'values'))))); $aggregate = FormControlAggregate::create('selected_items')->set_selector("#tag_collection input")->label('0 Selected'); $aggr_wrap = FormControlWrapper::create('tag_controls_aggregate')->add_class('aggregate_wrapper'); $aggr_wrap->append($aggregate); $delete = FormControlDropbutton::create('delete_dropbutton'); $delete->append(FormControlButton::create('action')->set_caption(_t('Delete selected'))->set_properties(array('title' => _t('Delete selected'), 'value' => 'delete'))); $rename_text = FormControlText::create('rename_text'); $rename = FormControlDropbutton::create('rename_dropbutton'); $rename->append(FormControlButton::create('action')->set_caption(_t('Rename selected'))->set_properties(array('title' => _t('Rename selected'), 'value' => 'rename'))); $tag_controls = $form->append(FormControlWrapper::create('tag_controls'))->add_class("container tag_controls"); $tag_controls->append($aggr_wrap); $tag_controls->append($rename_text); $tag_controls->append($rename); $tag_controls->append($delete); $tag_controls->append(FormControlWrapper::create('selected_tags')->set_setting('wrap_element', 'ul')->set_property('id', 'selected_tags')); if (count($this->theme->tags) > 0) { $tag_collection = $form->append(FormControlWrapper::create('tag_collection')->add_class('container items')->set_setting('wrap_element', 'ul')->set_property('id', 'tag_collection')); $listitems = $this->get_tag_listitems(); foreach ($listitems as $item) { $tag_collection->append($item); } } else { $tag_collection = $form->append(FormControlStatic::create('<p>' . _t('No tags could be found to match the query criteria.') . '</p>')); } $form->on_success(array($this, 'process_tags')); $this->theme->form = $form; Stack::add('admin_header_javascript', 'visualsearch'); Stack::add('admin_header_javascript', 'manage-js'); Stack::add('admin_stylesheet', 'visualsearch-css'); Stack::add('admin_stylesheet', 'visualsearch-datauri-css'); $this->display('tags'); }
<?php namespace Habari; if (!defined('HABARI_PATH')) { die('No direct access'); } $theme->display('header'); ?> <div class="container main plugins"> <?php $facet = FormControlFacet::create('search')->set_property('data-facet-config', array('onsearch' => '$("plugin_collection").manager("quicksearch", self.data("visualsearch").searchQuery.facets());', 'facetsURL' => URL::get('admin_ajax_tag_facets', array('context' => 'tag_facets', 'component' => 'facets')), 'valuesURL' => URL::get('admin_ajax_tag_facets', array('context' => 'tag_facets', 'component' => 'values')))); echo $facet->pre_out(); echo $facet->get($theme); ?> </div> <div id="plugin_collection"> <?php if (isset($config_plugin)) { ?> <div class="container main plugins configureplugin" id="configureplugin"> <h2><?php echo $config_plugin['info']->name; ?> · <?php echo $config_plugin_caption; ?> </h2> <?php
/** * Handles POST values from /manage/posts. * Used to control what content to show / manage. */ public function post_posts() { // Simply pass $_GET to the function, it's save as only values we understand will be read $this->fetch_posts($_GET); // Check which values have been passed and translate them for the faceted seach $search_values = array(); foreach ($this->locals as $varname => $default) { if (isset($_GET[$varname])) { switch ($varname) { case 'type': $search_values[] = 'type: ' . Post::type_name($_GET['type']); break; case 'status': $search_values[] = 'status: ' . Post::status_name($_GET['status']); break; case 'tag': $tags = explode(',', $_GET['tag']); foreach ($tags as $tag) { $search_values[] = 'tag: ' . $tag; } break; case 'author': $search_values[] = 'author: ' . User::get($_GET['author'])->username; break; default: $search_values[] = $varname . ': ' . $_GET[$varname]; } } } if (count($search_values) > 0) { $search_value = implode(' ', $search_values); } else { $search_value = ''; } // Create search controls and global buttons for the manage page $search = FormControlFacet::create('search'); $search->set_value($search_value)->set_property('data-facet-config', array('onsearch' => '$(".posts").manager("update", self.data("visualsearch").searchQuery.facets());', 'facetsURL' => URL::get('admin_ajax_facets', array('context' => 'facets', 'page' => 'manage', 'component' => 'facets')), 'valuesURL' => URL::get('admin_ajax_facets', array('context' => 'facets', 'page' => 'manage', 'component' => 'values')))); $navigation = FormControlStatic::create('navigation')->set_static('<a href="" id="nav_prev" class="navigation">' . _t('Previous page') . '</a>' . '<a href="" id="nav_next" class="navigation">' . _t('Next page') . '</a>'); $aggregate = FormControlAggregate::create('selected_items')->set_selector('.post_item')->label('None Selected'); $page_actions = FormControlDropbutton::create('page_actions'); $page_actions->append(FormControlSubmit::create('delete')->set_caption(_t('Delete Selected'))->set_properties(array('onclick' => 'itemManage.update(\'delete\');return false;', 'title' => _t('Delete Selected')))); Plugins::act('posts_manage_actions', $page_actions); $form = new FormUI('manage'); $form->append($search); $form->append($navigation); $form->append($aggregate); $form->append($page_actions); $this->theme->form = $form; $this->theme->admin_page = _t('Manage Posts'); $this->theme->admin_title = _t('Manage Posts'); Stack::add('admin_header_javascript', 'visualsearch'); Stack::add('admin_header_javascript', 'manage-js'); Stack::add('admin_stylesheet', 'visualsearch-css'); Stack::add('admin_stylesheet', 'visualsearch-datauri-css'); $this->display('posts'); }