/** * Helper function to list tags/categories as keywords separated by comma. * * @param array $array the array of the tags or categories to list */ private static function getMetaKeywords() { global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_current_category, $_zp_gallery_page, $_zp_zenpage; $words = ''; if (is_object($_zp_current_album) or is_object($_zp_current_image)) { $tags = getTags(); $words .= htmlmetatags::getMetaAlbumAndImageTags($tags, "gallery"); } else { if ($_zp_gallery_page === "index.php") { $tags = array_keys(getAllTagsCount(true)); // get all if no specific item is set $words .= htmlmetatags::getMetaAlbumAndImageTags($tags, "gallery"); } } if (extensionEnabled('zenpage')) { if (is_NewsArticle()) { $tags = getNewsCategories(getNewsID()); $words .= htmlmetatags::getMetaAlbumAndImageTags($tags, "zenpage"); $tags = getTags(); $words = $words . "," . htmlmetatags::getMetaAlbumAndImageTags($tags, "gallery"); } else { if (is_Pages()) { $tags = getTags(); $words = htmlmetatags::getMetaAlbumAndImageTags($tags, "gallery"); } else { if (is_News()) { $tags = $_zp_zenpage->getAllCategories(); $words .= htmlmetatags::getMetaAlbumAndImageTags($tags, "zenpage"); } else { if (is_NewsCategory()) { $words .= $_zp_current_category->getTitle(); } } } } } return $words; }
function tagSuggestJS($exclude_unassigned = false, $checkaccess = false) { // the scripts needed ?> <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"> // <!-- <![CDATA[ var _tagList = [<?php echo $list; ?> ]; $(function() { $('#search_input, #edit-editable_4, .tagsuggest').tagSuggest({separator: '<?php echo $tagseparator; ?> ', tags: _tagList}) }); // ]]> --> </script> <?php }
/** * Either prints all of the galleries tgs as a UL list or a cloud * * @param string $option "cloud" for tag cloud, "list" for simple list * @param string $class CSS class * @param string $sort "results" for relevance list, "random" for random ordering, otherwise the list is alphabetical * @param bool $counter TRUE if you want the tag count within brackets behind the tag * @param bool $links set to TRUE to have tag search links included with the tag. * @param int $maxfontsize largest font size the cloud should display * @param int $maxcount the floor count for setting the cloud font size to $maxfontsize * @param int $mincount the minimum count for a tag to appear in the output * @param int $limit set to limit the number of tags displayed to the top $numtags * @param int $minfontsize minimum font size the cloud should display * @param bool $exclude_unassigned True or false if you wish to exclude tags that are not assigne to any item (default: true) * @param bool $checkaccess True or false (default: false) if you wish to exclude tags that are assigned to items (or are not assigned at all) the visitor is not allowed to see * Beware that this may cause overhead on large sites. Usage of the static_html_cache is strongely recommended then. * @since 1.1 */ function printAllTagsAs($option, $class = '', $sort = NULL, $counter = FALSE, $links = TRUE, $maxfontsize = 2, $maxcount = 50, $mincount = 1, $limit = NULL, $minfontsize = 0.8, $exclude_unassigned = true, $checkaccess = false) { global $_zp_current_search; $option = strtolower($option); if ($class != "") { $class = ' class="' . $class . '"'; } $tagcount = getAllTagsCount($exclude_unassigned, $checkaccess); if (!is_array($tagcount)) { return false; } switch ($sort) { case 'results': arsort($tagcount); if (!is_null($limit)) { $tagcount = array_slice($tagcount, 0, $limit); } break; case 'random': if (!is_null($limit)) { $tagcount = array_slice($tagcount, 0, $limit); } shuffle_assoc($tagcount); break; default: break; } ?> <ul<?php echo $class; ?> > <?php if (count($tagcount) > 0) { foreach ($tagcount as $key => $val) { if (!$counter) { $counter = ""; } else { $counter = " (" . $val . ") "; } if ($option == "cloud") { // calculate font sizes, formula from wikipedia if ($val <= $mincount) { $size = $minfontsize; } else { $size = min(max(round($maxfontsize * ($val - $mincount) / ($maxcount - $mincount), 2), $minfontsize), $maxfontsize); } $size = str_replace(',', '.', $size); $size = ' style="font-size:' . $size . 'em;"'; } else { $size = ''; } if ($val >= $mincount) { if ($links) { if (is_object($_zp_current_search)) { $albumlist = $_zp_current_search->getAlbumList(); } else { $albumlist = NULL; } $link = getSearchURL(search_quote($key), '', 'tags', 0, array('albums' => $albumlist)); ?> <li> <a href="<?php echo html_encode($link); ?> "<?php echo $size; ?> ><?php echo $key . $counter; ?> </a> </li> <?php } else { ?> <li<?php echo $size; ?> ><?php echo $key . $counter; ?> </li> <?php } } } // while end } else { ?> <li><?php echo gettext('No popular tags'); ?> </li> <?php } ?> </ul> <?php }
/** * Creates an unordered checklist of the tags * * @param object $that Object for which to get the tags * @param string $postit prefix to prepend for posting * @param bool $showCounts set to true to get tag count displayed */ function tagSelector($that, $postit, $showCounts = false, $mostused = false, $addnew = true, $resizeable = false, $class = 'checkTagsAuto') { global $_zp_admin_ordered_taglist, $_zp_admin_LC_taglist; if (is_null($_zp_admin_ordered_taglist)) { if ($mostused || $showCounts) { $counts = getAllTagsCount(); if ($mostused) { arsort($counts, SORT_NUMERIC); } $them = array(); foreach ($counts as $tag => $count) { $them[] = $tag; } } else { $them = getAllTagsUnique(); } $_zp_admin_ordered_taglist = $them; $_zp_admin_LC_taglist = array(); foreach ($them as $tag) { $_zp_admin_LC_taglist[] = mb_strtolower($tag); } } else { $them = $_zp_admin_ordered_taglist; } if (is_null($that)) { $tags = array(); } else { $tags = $that->getTags(); } if (count($tags) > 0) { foreach ($tags as $tag) { $tagLC = mb_strtolower($tag); $key = array_search($tagLC, $_zp_admin_LC_taglist); if ($key !== false) { unset($them[$key]); } } } if ($resizeable) { $tagclass = 'resizeable_tagchecklist'; ?> <script> $(function() { $("#resizable_<?php echo $postit; ?> ").resizable({ <?php if (is_bool($resizeable)) { ?> maxWidth: 250, <?php } ?> minWidth: 250, minHeight: 120, resize: function(event, ui) { $('#list_<?php echo $postit; ?> ').height($('#resizable_<?php echo $postit; ?> ').height()); } }); });</script> <?php } else { $tagclass = 'tagchecklist'; } if ($addnew) { ?> <span class="new_tag displayinline" > <a href="javascript:addNewTag('<?php echo $postit; ?> ');" title="<?php echo gettext('add tag'); ?> "> <img src="images/add.png" title="<?php echo gettext('add tag'); ?> "/> </a> <input class="tagsuggest <?php echo $class; ?> " type="text" value="" name="newtag_<?php echo $postit; ?> " id="newtag_<?php echo $postit; ?> " /> </span> <?php } ?> <div id="resizable_<?php echo $postit; ?> " class="tag_div"> <ul id="list_<?php echo $postit; ?> " class="<?php echo $tagclass; ?> "> <?php if ($showCounts) { $displaylist = array(); foreach ($them as $tag) { $displaylist[$tag . ' [' . $counts[$tag] . ']'] = $tag; } } else { $displaylist = $them; } if (count($tags) > 0) { generateUnorderedListFromArray($tags, $tags, $postit, false, !$mostused, $showCounts, $class); ?> <li><hr /></li> <?php } generateUnorderedListFromArray(array(), $displaylist, $postit, false, !$mostused, $showCounts, $class); ?> </ul> </div> <?php }
/** * Creates an unordered checklist of the tags * * @param object $that Object for which to get the tags * @param string $postit prefix to prepend for posting * @param bool $showCounts set to true to get tag count displayed */ function tagSelector($that, $postit, $showCounts = false, $mostused = false, $addnew = true) { global $_zp_admin_ordered_taglist, $_zp_admin_LC_taglist, $_zp_UTF8, $jaTagList; if (is_null($_zp_admin_ordered_taglist)) { if ($mostused || $showCounts) { $counts = getAllTagsCount(); if ($mostused) { arsort($counts, SORT_NUMERIC); } $them = array(); foreach ($counts as $tag => $count) { $them[] = $tag; } } else { $them = getAllTagsUnique(); } $_zp_admin_ordered_taglist = $them; $_zp_admin_LC_taglist = array(); foreach ($them as $tag) { $_zp_admin_LC_taglist[] = $_zp_UTF8->strtolower($tag); } } else { $them = $_zp_admin_ordered_taglist; } if (is_null($that)) { $tags = array(); } else { $tags = $that->getTags(); } if (count($tags) > 0) { foreach ($tags as $tag) { $tagLC = $_zp_UTF8->strtolower($tag); $key = array_search($tagLC, $_zp_admin_LC_taglist); if ($key !== false) { unset($them[$key]); } } } $hr = ''; if ($addnew) { if (count($tags) == 0) { $hr = '<li><hr /></li>'; } ?> <span class="new_tag displayinline" > <a href="javascript:addNewTag('<?php echo $postit; ?> ','<?php echo gettext('tag set!'); ?> ');" title="<?php echo gettext('add tag'); ?> "> <img src="images/add.png" title="<?php echo gettext('add tag'); ?> "/> </a> <input type="text" value="" name="newtag_<?php echo $postit; ?> " id="newtag_<?php echo $postit; ?> " /> </span> <?php } ?> <ul id="list_<?php echo $postit; ?> " class="tagchecklist"> <?php echo $hr; ?> <?php if ($showCounts) { $displaylist = array(); foreach ($them as $tag) { $displaylist[$tag . ' [' . $counts[$tag] . ']'] = $tag; } } else { $displaylist = $them; } if (count($tags) > 0) { generateUnorderedListFromArray($tags, $tags, $postit, false, !$mostused, $showCounts); ?> <li><hr /></li> <?php } generateUnorderedListFromArray(array(), $displaylist, $postit, false, !$mostused, $showCounts); ?> </ul> <?php }
/** * Either prints all of the galleries tgs as a UL list or a cloud * * @param string $option "cloud" for tag cloud, "list" for simple list * @param string $class CSS class * @param string $sort "results" for relevance list, "abc" for alphabetical, blank for unsorted * @param bool $counter TRUE if you want the tag count within brackets behind the tag * @param bool $links set to TRUE to have tag search links included with the tag. * @param int $maxfontsize largest font size the cloud should display * @param int $maxcount the floor count for setting the cloud font size to $maxfontsize * @param int $mincount the minimum count for a tag to appear in the output * @param int $limit set to limit the number of tags displayed to the top $numtags * @param int $minfontsize minimum font size the cloud should display * @since 1.1 */ function printAllTagsAs($option, $class = '', $sort = 'abc', $counter = FALSE, $links = TRUE, $maxfontsize = 2, $maxcount = 50, $mincount = 10, $limit = NULL, $minfontsize = 0.8) { global $_zp_current_search; $option = strtolower($option); if ($class != "") { $class = "class=\"" . $class . "\""; } $tagcount = getAllTagsCount(); if (!is_array($tagcount)) { return false; } if ($sort == "results") { arsort($tagcount); } if (!is_null($limit)) { $tagcount = array_slice($tagcount, 0, $limit); } $list = ''; echo "<ul " . $class . ">\n"; foreach ($tagcount as $key => $val) { if (!$counter) { $counter = ""; } else { $counter = " (" . $val . ") "; } if ($option == "cloud") { // calculate font sizes, formula from wikipedia if ($val <= $mincount) { $size = $minfontsize; } else { $size = min(max(round($maxfontsize * ($val - $mincount) / ($maxcount - $mincount), 2), $minfontsize), $maxfontsize); } $size = str_replace(',', '.', $size); $size = " style=\"font-size:" . $size . "em;\""; } else { $size = ''; } if ($val >= $mincount) { if ($links) { if (is_object($_zp_current_search)) { $albumlist = $_zp_current_search->album_list; } else { $albumlist = NULL; } $lkey = search_quote($key); $list .= "\t<li><a href=\"" . html_encode(getSearchURL($lkey, '', 'tags', 0, array('albums' => $albumlist))) . "\"{$size} rel=\"nofollow\">" . $key . $counter . "</a></li>\n"; } else { $list .= "\t<li{$size}>" . $key . $counter . "</li>\n"; } } } // while end if ($list) { echo $list; } else { echo '<li>' . gettext('No popular tags') . "</li>\n"; } echo "</ul>\n"; }
/** * Either prints all of the galleries tgs as a UL list or a cloud * * @param string $option "cloud" for tag cloud, "list" for simple list * @param string $class CSS class * @param string $sort "results" for relevance list, "abc" for alphabetical, blank for unsorted * @param bool $counter TRUE if you want the tag count within brackets behind the tag * @param bool $links set to TRUE to have tag search links included with the tag. * @param int $maxfontsize largest font size the cloud should display * @param int $maxcount the maximum count for a tag to appear in the output * @param int $mincount the minimum count for a tag to appear in the output * @param int $limit set to limit the number of tags displayed to the top $numtags * @since 1.1 */ function printAllTagsAs($option, $class = '', $sort = 'abc', $counter = FALSE, $links = TRUE, $maxfontsize = 2, $maxcount = 50, $mincount = 10, $limit = NULL) { define('MINFONTSIZE', 0.8); $option = strtolower($option); if ($class != "") { $class = "class=\"" . $class . "\""; } $tagcount = getAllTagsCount(); if (!is_array($tagcount)) { return false; } if ($sort == "results") { arsort($tagcount); } if (!is_null($limit)) { $tagcount = array_slice($tagcount, 0, $limit); } echo "<ul " . $class . ">\n"; foreach ($tagcount as $key => $val) { if (!$counter) { $counter = ""; } else { $counter = " (" . $val . ") "; } if ($option == "cloud") { // calculate font sizes, formula from wikipedia if ($val <= $mincount) { $size = MINFONTSIZE; } else { $size = min(max(round($maxfontsize * ($val - $mincount) / ($maxcount - $mincount), 2), MINFONTSIZE), $maxfontsize); } $size = str_replace(',', '.', $size); $size = " style=\"font-size:" . $size . "em;\""; } else { $size = ''; } if ($val >= $mincount) { if (!$links) { echo "\t<li{$size}>" . $key . $counter . "</li>\n"; } else { $key = str_replace('"', '', $key); echo "\t<li><a href=\"" . htmlspecialchars(getSearchURL($key, '', SEARCH_TAGS, 0, 0)) . "\"{$size} rel=\"nofollow\">" . $key . $counter . "</a></li>\n"; } } } // while end echo "</ul>\n"; }
/** * Creates an unordered checklist of the tags * * @param object $that Object for which to get the tags * @param string $postit prefix to prepend for posting * @param bool $showCounts set to true to get tag count displayed */ function tagSelector($that, $postit, $showCounts = false, $mostused = false) { global $_zp_loggedin, $_zp_admin_ordered_taglist, $_zp_admin_LC_taglist, $_zp_UTF8; if (is_null($_zp_admin_ordered_taglist)) { if ($mostused || $showCounts) { $counts = getAllTagsCount(); if ($mostused) { arsort($counts, SORT_NUMERIC); } $them = array(); foreach ($counts as $tag => $count) { $them[] = $tag; } } else { $them = getAllTagsUnique(); } $_zp_admin_ordered_taglist = $them; $_zp_admin_LC_taglist = array(); foreach ($them as $tag) { $_zp_admin_LC_taglist[] = $_zp_UTF8->strtolower($tag); } } else { $them = $_zp_admin_ordered_taglist; } if (is_null($that)) { $tags = array(); } else { $tags = $that->getTags(); } if (count($tags) > 0) { foreach ($tags as $tag) { $tagLC = $_zp_UTF8->strtolower($tag); $key = array_search($tagLC, $_zp_admin_LC_taglist); if ($key !== false) { unset($them[$key]); } } } echo '<ul class="tagchecklist">' . "\n"; if ($showCounts) { $displaylist = array(); foreach ($them as $tag) { $displaylist[$tag . ' [' . $counts[$tag] . ']'] = $tag; } } else { $displaylist = $them; } if (count($tags) > 0) { generateUnorderedListFromArray($tags, $tags, $postit, false, true, false); echo '<hr>'; } generateUnorderedListFromArray(array(), $displaylist, $postit, false, true, false); echo '</ul>'; }