1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97:
<?php
$plugin_is_filter = 9 | THEME_PLUGIN;
$plugin_description = gettext("Enables jQuery tag suggestions on the search field.");
$plugin_author = "Malte Müller (acrylian), Stephen Billard (sbillard)";
$plugin_category = gettext('Misc');
$option_interface = 'tagsuggest';
zp_register_filter('theme_head', 'tagSuggestJS_frontend');
zp_register_filter('admin_head', 'tagSuggestJS_admin');
class tagsuggest {
function __construct() {
setOptionDefault('tagsuggest_excludeunassigned', 1);
setOptionDefault('tagsuggest_checkaccess', 0);
}
function getOptionsSupported() {
$options = array(
gettext('Exclude unassigned')
=> array(
'key' => 'tagsuggest_excludeunassigned',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Check if you wish to exclude tags are not assigned to any item.")),
gettext('Check tag access')
=> array(
'key' => 'tagsuggest_checkaccess',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Check if you wish to exclude tags that are assigned to items (or are not assigned at all) the visitor is not allowed to see. This overrides the exlude unassigned option. <p class='notebox'><strong>Note:</strong> Beware that this may cause overhead on larger sites. The usage of the static_html_cache plugin is recommended.</p>"))
);
return $options;
}
}
function tagSuggestJS_admin() {
tagSuggestJS(false);
}
function tagSuggestJS_frontend() {
$exclude_unassigned = getOption('tagsuggest_excludeunassigned');
$checkaccess = getOption('tagsuggest_checkaccess');
tagSuggestJS($exclude_unassigned,$checkaccess);
}
function tagSuggestJS($exclude_unassigned = false, $checkaccess = false) {
?>
<script type="text/javascript" src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/encoder.js"></script>
<script type="text/javascript" src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/tag.js"></script>
<?php
$css = getPlugin('tag_suggest/tag.css', true, true);
?>
<link type="text/css" rel="stylesheet" href="<?php echo pathurlencode($css); ?>" />
<?php
if ($checkaccess) {
$taglist = getAllTagsUnique(true);
} else {
if ($exclude_unassigned) {
$taglist = getAllTagsCount(true);
$taglist = array_keys($taglist);
} else {
$taglist = getAllTagsUnique(false);
}
}
$c = 0;
$list = '';
foreach ($taglist AS $tag) {
if ($c > 0)
$list .= ',';
$c++;
$list .= '"' . addslashes($tag) . '"';
}
if (OFFSET_PATH || getOption('search_space_is') == 'OR') {
$tagseparator = ' ';
} else {
$tagseparator = ',';
}
?>
<script type="text/javascript">
var _tagList = [<?php echo $list; ?>];
$(function() {
$('#search_input, #edit-editable_4, .tagsuggest').tagSuggest({separator: '<?php echo $tagseparator; ?>', tags: _tagList})
});
</script>
<?php
}
?>