Пример #1
0
    static function JS()
    {
        // the scripts needed
        ?>
		<script type="text/javascript" src="<?php 
        echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER;
        ?>
/tag_suggest/encoder.js"></script>
		<script type="text/javascript" src="<?php 
        echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER;
        ?>
/tag_suggest/tag.js"></script>
		<?php 
        $css = getPlugin('tag_suggest/tag.css', true, true);
        ?>
		<link type="text/css" rel="stylesheet" href="<?php 
        echo pathurlencode($css);
        ?>
" />
		<?php 
        $taglist = getAllTagsUnique(OFFSET_PATH ? false : NULL, OFFSET_PATH ? 0 : getOption('tag_suggest_threshold'));
        $tags = array();
        foreach ($taglist as $tag) {
            $tags[] = addslashes($tag);
        }
        if (OFFSET_PATH || getOption('search_space_is') == 'OR') {
            $tagseparator = ' ';
        } else {
            $tagseparator = ',';
        }
        ?>
		<script type="text/javascript">
			// <!-- <![CDATA[
			var _tagList = ["<?php 
        echo implode($tags, '","');
        ?>
"];
			$(function () {
				$('#search_input, #edit-editable_4, .tagsuggest').tagSuggest({separator: '<?php 
        echo $tagseparator;
        ?>
', tags: _tagList, quoteSpecial: <?php 
        echo OFFSET_PATH ? 'false' : 'true';
        ?>
})
			});
			// ]]> -->
		</script>
		<?php 
    }
Пример #2
0
function tagSuggestJS()
{
    // 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 
    $taglist = getAllTagsUnique();
    $c = 0;
    $list = '';
    foreach ($taglist as $tag) {
        if ($c > 0) {
            $list .= ',';
        }
        $c++;
        $list .= '"' . addslashes(sanitize($tag, 3)) . '"';
    }
    ?>
	<script type="text/javascript">
		// <!-- <![CDATA[
		var _tagList = [<?php 
    echo $list;
    ?>
];
		$(function () {
			$('#search_input, #edit-editable_4').tagSuggest({ separator:'<?php 
    echo getOption('search_space_is') == 'OR' ? ' ' : ',';
    ?>
', tags: _tagList })
			});
		// ]]> -->
	</script>
	<?php 
}
Пример #3
0
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 
}
Пример #4
0
 /**
  * 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_article, $_zp_current_page, $_zp_current_category, $_zp_gallery_page, $_zp_CMS;
     $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(getAllTagsUnique(NULL, getOption('htmlmeta_tags_threshold')));
             // 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_CMS->getAllCategories();
                     $words .= htmlmetatags::getMetaAlbumAndImageTags($tags, "zenpage");
                 } else {
                     if (is_NewsCategory()) {
                         $words .= $_zp_current_category->getTitle();
                     }
                 }
             }
         }
     }
     return $words;
 }
Пример #5
0
/**
 * 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
 * @since 1.1
 */
function printAllTagsAs($option, $class = '', $sort = NULL, $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 = getAllTagsUnique(NULL, $mincount, true);
    if (!is_array($tagcount)) {
        return false;
    }
    arsort($tagcount);
    if (!is_null($limit)) {
        $tagcount = array_slice($tagcount, 0, $limit);
    }
    $keys = array_keys($tagcount);
    switch ($sort) {
        default:
            natcasesort($keys);
            break;
        case 'results':
            //already in tag count order
            break;
        case 'random':
            shuffle_assoc($keys);
            break;
    }
    ?>
	<ul<?php 
    echo $class;
    ?>
>
		<?php 
    if (count($tagcount) > 0) {
        foreach ($keys as $key) {
            $val = $tagcount[$key];
            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 ($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);
                ?>
" rel="nofollow"<?php 
                echo $size;
                ?>
><?php 
                echo str_replace(' ', '&nbsp;', html_encode($key)) . $counter;
                ?>
</a>
					</li>
					<?php 
            } else {
                ?>
					<li<?php 
                echo $size;
                ?>
><?php 
                echo str_replace(' ', '&nbsp;', html_encode($key)) . $counter;
                ?>
</li>
					<?php 
            }
        }
    } else {
        ?>
			<li><?php 
        echo gettext('No popular tags');
        ?>
</li>
			<?php 
    }
    ?>
	</ul>
	<?php 
}
Пример #6
0
<?php

/**
 * tag suggest plugin draft based on Remy Sharp's jQuery Tag Suggestion plugin
 * Just activate the plugin and the feature is available on the theme's search field.
 *
 * @author Malte Müller (acrylian), Stephen Billard (sbillard) - an adaption of Remy Sharp's <a href='http://remysharp.com/2007/12/28/jquery-tag-suggestion/ '>jQuery Tag Suggestion</a>
 * @version 1.0.0
 * @package plugins
 */
$plugin_description = gettext("Enables jQuery tag suggestions on the search field. Just activate the plugin and the feature is available on the theme's search field.");
$plugin_author = "Malte Müller (acrylian), Stephen Billard (sbillard) — " . gettext("an adaption of Remy Sharp's <a href='http://remysharp.com/2007/12/28/jquery-tag-suggestion/ '>jQuery Tag Suggestion</a>");
$plugin_version = '1.0.0';
$plugin_URL = "http://www.zenphoto.org/documentation/plugins/_plugins---tag_suggest.php.html";
// register the scripts needed
addPluginScript('<script type="text/javascript" src="' . WEBPATH . '/' . ZENFOLDER . '/js/tag.js"></script>');
addPluginScript('<link type="text/css" rel="stylesheet" href="' . WEBPATH . '/' . ZENFOLDER . '/plugins/tag_suggest/tag.css" />');
$taglist = getAllTagsUnique();
$c = 0;
$list = '';
foreach ($taglist as $tag) {
    if ($c > 0) {
        $list .= ',';
    }
    $c++;
    $list .= '"' . htmlspecialchars(htmlspecialchars_decode($tag), ENT_QUOTES) . '"';
}
$js = '<script type="text/javascript">' . '$(function () {' . "\$('#search_input').tagSuggest({" . 'tags: [' . $list . ']' . '});' . '});' . '</script>';
addPluginScript($js);
Пример #7
0
/**
 * 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 
}
Пример #8
0
/**
 * @deprecated
 * @since 1.0.1
 */
function getAllTagsCount($language = NULL)
{
    deprecated_functions::notify(gettext('Use getAllTagsUnique()'));
    return getAllTagsUnique($language, 1, true);
}
Пример #9
0
/**
 * 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 
}
Пример #10
0
/**
 * 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>';
}