Example #1
0
/**
 * Get all tags, to display in 'suggested tags' when editing an entry, or 
 * when inserting a tag.
 */
function getalltags()
{
    $minsize = 11;
    $maxsize = 19;
    $amount = 1000;
    $tagcosmos = getTagCosmos($amount);
    foreach ($tagcosmos['tags'] as $key => $value) {
        // Calculate the size, depending on value.
        $nSize = round($minsize + $value / $tagcosmos['maxvalue'] * ($maxsize - $minsize));
        // Write the tags, we add events to them using jquery.
        $htmllinks[$key] = sprintf("<a style=\"font-size:%spx;\" rel=\"tag\" title=\"%s: %s, %s %s\">%s</a>\n", $nSize, lang('tags', 'tag'), $key, $value, lang('userbar', 'entries'), str_replace("+", " ", $key));
    }
    $output .= implode(" ", $htmllinks);
    echo $output;
}
Example #2
0
/**
 * Print out the current Tag Cosmos as a fancy tagcloud in HTML, with smaller
 * and larger tags, dependent on how often they occur. Returns the output as HTML.
 *
 * @return string
 */
function printTagCosmos()
{
    global $Paths, $Cfg, $Current_weblog;
    $tagcosmos = getTagCosmos(0, $Current_weblog);
    $htmllinks = array();
    // This is the factor we need to calculate the EM sizes. $minsize is 1 em,
    // $maxsize will be ($maxsize / $minsize) EM.. Take care if $tagcosmos['maxvalue'] == $tagcosmos['minvalue']
    if ($tagcosmos['maxvalue'] != $tagcosmos['minvalue']) {
        $factor = ($Cfg['tag_max_font'] - $Cfg['tag_min_font']) / ($tagcosmos['maxvalue'] - $tagcosmos['minvalue']) / $Cfg['tag_min_font'];
    } else {
        $factor = 0;
    }
    foreach ($tagcosmos['tags'] as $key => $value) {
        // Calculate the size, depending on value.
        $nSize = sprintf("%0.2f", 1 + ($value - $tagcosmos['minvalue']) * $factor);
        $htmllinks[$key] = sprintf("<a style=\"font-size:%sem;\" href=\"%s\"\r\n\t\t  rel=\"tag\" title=\"%s: %s, %s %s\">%s</a>\n", $nSize, tagLink($key, $template), lang('tags', 'tag'), $key, $value, lang('userbar', 'entries'), $key);
    }
    $output = "<div id='tagpage'>\n<h2>" . lang('tags', 'tags') . "</h2>\n";
    $output .= "<p>" . lang('tags', 'localcosmos_description') . "</p>\n";
    $output .= "<div id=\"tagcosmos\" style=\"font-size: {$Cfg['tag_min_font']}px;\">\n";
    $output .= implode("\n", $htmllinks);
    // Since it'll be built in, we don't want to display Marco's name on every page. Sorry Marco, you know we love you! ;-)
    // $output .= "<br/><br/><small>Taggerati extension for <a href=\"http://www.pivotlog.net/\">Pivot</a> by <a href=\"http://www.i-marco.nl/weblog/\">Marco van Hylckama Vlieg</a></small>";
    $output .= "</div>\n</div>\n\n";
    return $output;
}
Example #3
0
$tags = implode(", ", $tags);
?>
	<input type="text" name="f_keywords" id="f_keywords" size="60" class='input' value="<?php 
echo htmlspecialchars(stripslashes($tags));
?>
" />
	<input type="hidden" name="f_keywords_old" id="f_keywords_old" value="<?php 
echo htmlspecialchars(stripslashes($entry['keywords']));
?>
" />
	<br /><?php 
echo "<p style='width:450px;'><strong>" . lang('tags', 'suggested_tags') . ":</strong> <span id='suggestedtags'>";
$minsize = 11;
$maxsize = 19;
$amount = 50;
$tagcosmos = getTagCosmos($amount);
foreach ($tagcosmos['tags'] as $key => $value) {
    // Calculate the size, depending on value.
    $nSize = round($minsize + $value / $tagcosmos['maxvalue'] * ($maxsize - $minsize));
    // Write the tags, we add events to them using jquery.
    $htmllinks[$key] = sprintf("<a style=\"font-size:%spx;\" rel=\"tag\" title=\"%s: %s, %s %s\">%s</a>\n", $nSize, lang('tags', 'tag'), $key, $value, lang('userbar', 'entries'), str_replace("+", " ", $key));
}
$output .= implode(" ", $htmllinks);
if ($amount < $tagcosmos['amount']) {
    // We need to print the 'all' link..
    $output .= sprintf('<em>(<a href="javascript:getalltags(\'\',\'entrypage\');">%s</a>)</em>', lang('general', 'all'));
}
$output .= "</span></p>";
echo $output;
?>
 </td>
Example #4
0
/**
 * Display a small tagcloud.
 *
 * @param array $params
 * @return string
 */
function smarty_tagcloud($params)
{
    global $PIVOTX;
    $params = cleanParams($params);
    $minsize = getDefault($params['minsize'], $PIVOTX['config']->get('tag_min_font'));
    $maxsize = getDefault($params['maxsize'], $PIVOTX['config']->get('tag_max_font'));
    $amount = getDefault($params['amount'], $PIVOTX['config']->get('tag_cloud_amount'));
    $sep = getDefault($params['sep'], ", ");
    $template = $params['template'];
    $underscore = getDefault($params['underscore'], false);
    if (!empty($params['exclude'])) {
        $exclude = explode(',', $params['exclude']);
    } else {
        $exclude = "";
    }
    $tagcosmos = getTagCosmos($amount, '', '', $exclude);
    // Abort immediately if there are no tags.
    if ($tagcosmos['amount'] == 0) {
        return '';
    }
    // This is the factor we need to calculate the EM sizes. $minsize is 1 em,
    // $maxsize will be ($maxsize / $minsize) EM.. Take care if $tagcosmos['maxvalue'] == $tagcosmos['minvalue']
    if ($tagcosmos['maxvalue'] != $tagcosmos['minvalue']) {
        $factor = ($maxsize - $minsize) / ($tagcosmos['maxvalue'] - $tagcosmos['minvalue']) / $minsize;
    } else {
        $factor = 0;
    }
    $htmllinks = array();
    foreach ($tagcosmos['tags'] as $key => $value) {
        // Calculate the size, depending on value.
        $nSize = sprintf("%0.2f", 1 + ($value - $tagcosmos['minvalue']) * $factor);
        $out_key = $key;
        if ($underscore !== false) {
            $out_key = str_replace('_', $underscore, $key);
        }
        $htmllinks[$key] = sprintf("<a style=\"font-size:%sem;\" href=\"%s\" rel=\"tag\" title=\"%s: %s, %s %s\">%s</a>", $nSize, tagLink($key, $template), __('Tag'), $out_key, $value, __('Entries'), $out_key);
    }
    $output = "<div id='tagcloud' style='font-size: {$minsize}px;'>";
    $output .= implode($sep, $htmllinks);
    $link = tagLink('sometag', $template);
    if ($PIVOTX['config']->get('mod_rewrite') == 0) {
        $link = str_replace('t=sometag', 'x=tagpage', $link);
    } else {
        $prefix = getDefault($PIVOTX['config']->get('localised_tag_prefix'), 'tag');
        $link = str_replace("{$prefix}/sometag", "tags", $link);
    }
    if ($tagcosmos['amount'] > $amount) {
        $output .= sprintf('<em>(<a href="%s">%s</a>)</em>', $link, __('all'));
    }
    $output .= "</div>";
    return $output;
}
Example #5
0
/**
 * Print out the current Tag Cosmos as a fancy tagcloud in HTML, with smaller
 * and larger tags, dependent on how often they occur. Returns the output as HTML.
 *
 * @return string
 */
function printTagCosmos()
{
    global $PIVOTX;
    $tagcosmos = getTagCosmos(0, $PIVOTX['weblogs']->getCurrent());
    $htmllinks = array();
    // This is the factor we need to calculate the EM sizes. $minsize is 1 em,
    // $maxsize will be ($maxsize / $minsize) EM.. Take care if $tagcosmos['maxvalue'] == $tagcosmos['minvalue']
    if ($tagcosmos['maxvalue'] != $tagcosmos['minvalue']) {
        $factor = ($PIVOTX['config']->get('tag_max_font') - $PIVOTX['config']->get('tag_min_font')) / ($tagcosmos['maxvalue'] - $tagcosmos['minvalue']) / $PIVOTX['config']->get('tag_min_font');
    } else {
        $factor = 0;
    }
    foreach ($tagcosmos['tags'] as $key => $value) {
        // Calculate the size, depending on value.
        $nSize = sprintf("%0.2f", 1 + ($value - $tagcosmos['minvalue']) * $factor);
        $htmllinks[$key] = sprintf("<a style=\"font-size:%sem;\" href=\"%s\"\n          rel=\"tag\" title=\"%s: %s, %s %s\">%s</a>\n", $nSize, tagLink($key, $template), __('Tag'), $key, $value, __('Entries'), $key);
    }
    $output = "<div id='tagpage'>\n<h2>" . __('Tags') . "</h2>\n";
    $output .= "<p>" . __('This is the local Tag Cosmos for this weblog. The larger the tag, the more entries on this blog are related to it. The tags are ordered alphabetically. Click on any tag to find out more.<br/><br/>') . "</p>\n";
    $output .= "<div id=\"tagcosmos\" style=\"font-size: {" . $PIVOTX['config']->get('tag_min_font') . "}px;\">\n";
    $output .= implode("\n", $htmllinks);
    $output .= "</div>\n</div>\n\n";
    return $output;
}
Example #6
0
 public static function ext_getTagSuggest()
 {
     $tag = safeString($_GET['q']);
     $tagcosmos = getTagCosmos(50, '', $tag);
     $output = "";
     if (is_array($tagcosmos) && !empty($tagcosmos)) {
         foreach ($tagcosmos['tags'] as $key => $value) {
             $output .= $key . "\n";
         }
     }
     echo $output;
 }
/**
 * Display a small tagcloud.
 *
 * @param integer $amount
 * @param integer $minsize
 * @param integer $maxsize
 * @param string $template
 * @return string
 */
function snippet_tagcloud($amount = 0, $minsize = 0, $maxsize = 0, $template = "")
{
    global $Paths, $Current_weblog, $Cfg;
    if ($minsize == 0) {
        $minsize = 8;
    }
    if ($maxsize == 0) {
        $maxsize = 17;
    }
    if ($amount == 0) {
        $amount = 20;
    }
    $tagcosmos = getTagCosmos($amount, $Current_weblog);
    // This is the factor we need to calculate the EM sizes. $minsize is 1 em,
    // $maxsize will be ($maxsize / $minsize) EM.. Take care if $tagcosmos['maxvalue'] == $tagcosmos['minvalue']
    if ($tagcosmos['maxvalue'] != $tagcosmos['minvalue']) {
        $factor = ($maxsize - $minsize) / ($tagcosmos['maxvalue'] - $tagcosmos['minvalue']) / $minsize;
    } else {
        $factor = 0;
    }
    foreach ($tagcosmos['tags'] as $key => $value) {
        // Calculate the size, depending on value.
        $nSize = sprintf("%0.2f", 1 + ($value - $tagcosmos['minvalue']) * $factor);
        $htmllinks[$key] = sprintf("<a style=\"font-size:%sem;\" href=\"%s\"\r\n\t\t  rel=\"tag\" title=\"%s: %s, %s %s\">%s</a>\n", $nSize, tagLink($key, $template), lang('tags', 'tag'), $key, $value, lang('userbar', 'entries'), $key);
    }
    $output = "<div id='tagcloud' style='font-size: {$minsize}px;'>";
    $output .= implode(" ", $htmllinks);
    if (para_weblog_needed($Current_weblog)) {
        $para .= "?w=" . para_weblog($Current_weblog);
        $para .= $template != "" ? "&amp;t={$template}" : "";
    } else {
        $para = $template != "" ? "?t={$template}" : "";
    }
    if ($Cfg['mod_rewrite'] == 0) {
        $link = $Paths['pivot_url'] . "tags.php";
    } else {
        $link = $Paths['log_url'] . "tags";
    }
    $output .= sprintf('<em>(<a href="%s%s">%s</a>)</em>', $link, $para, lang('general', 'all'));
    $output .= "</div>";
    return $output;
}