Plugin Directory

Changeset 153397


Ignore:
Timestamp:
09/09/2009 11:57:28 PM (17 years ago)
Author:
davidjmillerorg
Message:

Correction on the mistaken release of version 2.13

Location:
similarity
Files:
17 added
2 edited

Legend:

Unmodified
Added
Removed
  • similarity/trunk/readme.txt

    r153287 r153397  
    4848== Changelog ==
    4949
     50= 2.13.1 =
     51* New options make it possible to layout and style the php function generated lists (for sidebars) independent of the auto-generated list.
     52
    5053= 2.13 =
    51 * New options make it possible to layout and style the php function generated lists (for sidebars) independent of the auto-generated list.
     54* Mistaken release - corrected in 2.13.1.
    5255
    5356= 2.12 =
  • similarity/trunk/similarity.php

    r153286 r153397  
    33Plugin Name: Similarity
    44Plugin URI: http://www.davidjmiller.org/2008/similarity/
    5 Description: Returns links to similar posts. Similarity is determined by the way posts are tagged or by their categories. Compatible with Wordpress 2.3 and above. (Tested on 2.3, 2.5, 2.6, 2.7)
    6 Version: 2.13
     5Description: Returns links to similar posts. Similarity is determined by the way posts are tagged or by their categories. Compatible with Wordpress 2.3 and above. (Tested on 2.3, 2.5, 2.6, 2.7, 2.8)
     6Version: 2.13.1
    77Author: David Miller
    88Author URI: http://www.davidjmiller.org/
     
    1616        e.g.: <?php sim_by_tag_multi(); ?> determines similarity based on the tags applied to the first post on milti-post pages
    1717        e.g.: <?php sim_by_cat_multi(); ?> determines similarity based on the categories assigned to the first post on milti-post pages
    18         e.g.: <?php sim_by_mix_multi(); ?> determines similarity based on the categories and tags assigned to the first post on milti-post pages weighting each according to the ratio you assign
     18        e.g.: <?php sim_by_mix(multi); ?> determines similarity based on the categories and tags assigned to the first post on milti-post pages weighting each according to the ratio you assign
    1919    Shortcodes:
    2020        e.g.: [SIM-BY-TAG]
     
    3131function sim_by_tag() {
    3232    $list = get_list("tag");
    33     echo '<div class="similarity">';
    3433    echo print_similarity($list);
    35     echo '</div><!-- Similarity - Sim_by_Tag -->';
     34    echo '<!-- Similarity - Sim_by_Tag -->';
    3635}
    3736function sim_by_cat() {
    3837    $list = get_list("cat");
    39     echo '<div class="similarity">';
    4038    echo print_similarity($list);
    41     echo '</div><!-- Similarity - Sim_by_Cat -->';
     39    echo '<!-- Similarity - Sim_by_Cat -->';
     40}
     41function sim_by_mix_multi() {
     42    $taglist = get_list("firstt");
     43    $catlist = get_list("firstc");
     44    $list = mix_lists($taglist, $catlist);
     45    echo print_similarity($list);
     46    echo '<!-- Similarity - Sim_by_Mix -->';
     47}
     48function sim_by_tag_multi() {
     49    $list = get_list("firstt");
     50    echo print_similarity($list);
     51    echo '<!-- Similarity - Sim_by_Tag -->';
     52}
     53function sim_by_cat_multi() {
     54    $list = get_list("firstc");
     55    echo print_similarity($list);
     56    echo '<!-- Similarity - Sim_by_Cat -->';
    4257}
    4358function sim_by_mix() {
     
    4560    $catlist = get_list("cat");
    4661    $list = mix_lists($taglist, $catlist);
    47     echo '<div class="similarity">';
    4862    echo print_similarity($list);
    49     echo '</div><!-- Similarity - Sim_by_Mix -->';
    50 }
    51 function sim_by_tag_multi() {
    52     $list = get_list("firstt");
    53     echo '<div class="similarity_sb">';
    54     echo print_similarity($list);
    55     echo '</div><!-- Similarity - Sim_by_Tag -->';
    56 }
    57 function sim_by_cat_multi() {
    58     $list = get_list("firstc");
    59     echo '<div class="similarity_sb">';
    60     echo print_similarity($list);
    61     echo '</div><!-- Similarity - Sim_by_Cat -->';
    62 }
    63 function sim_by_mix_multi() {
    64     $taglist = get_list("firstt");
    65     $catlist = get_list("firstc");
    66     $list = mix_lists($taglist, $catlist);
    67     echo '<div class="similarity_sb">';
    68     echo print_similarity($list);
    69     echo '</div><!-- Similarity - Sim_by_Mix -->';
     63    echo '<!-- Similarity - Sim_by_Mix -->';
    7064}
    7165
     
    9286            $catlist = get_list("cat");
    9387            $list = mix_lists($taglist, $catlist);
    94             return $content.'<div class="similarity">'.print_similarity($list).'</div><!-- Mix -->';
     88            return $content.'<div class="similarity">'.print_similarity($list, 'auto').'</div><!-- Mix -->';
    9589            break;
    9690        default:
     
    114108}
    115109
    116 function print_similarity($list) {
     110function print_similarity($list, $template = 'default') {
    117111    global $current_user;
    118112    $options = get_option(basename(__FILE__, ".php"));
    119113    $limit = stripslashes($options['limit']);
    120114    $none_text = stripslashes($options['none_text']);
    121     $prefix = stripslashes($options['prefix']);
    122     $suffix = stripslashes($options['suffix']);
    123     $format = stripslashes($options['format']);
     115    if ($template == 'auto') {
     116        $prefix = stripslashes($options['auto_prefix']);
     117        $suffix = stripslashes($options['auto_suffix']);
     118        $format = stripslashes($options['auto_format']);
     119        $output_template = stripslashes($options['auto_output_template']);
     120    } else {
     121        $prefix = stripslashes($options['prefix']);
     122        $suffix = stripslashes($options['suffix']);
     123        $format = stripslashes($options['format']);
     124        $output_template = stripslashes($options['output_template']);
     125    }
    124126    $minimum_strength = stripslashes($options['minimum_strength']);
    125127    $random_min = stripslashes($options['random_min']);
    126     $output_template = stripslashes($options['output_template']);
    127128    // an empty output_template makes no sense so we fall back to the default
    128129    if ($output_template == '') $output_template = '<li>{link} ({strength})</li>';
     
    428429$default_options['format'] = 'value';
    429430$default_options['output_template'] = '<li>{link} ({strength})</li>';
     431$default_options['auto_prefix'] = '<ul>';
     432$default_options['auto_suffix'] = '</ul>';
     433$default_options['auto_format'] = 'value';
     434$default_options['auto_output_template'] = '<li>{link} ({strength})</li>';
    430435$default_options['tag_weight'] = 1;
    431436$default_options['cat_weight'] = 1;
     
    450455        $options['format'] = $_POST['format'];
    451456        $options['output_template'] = $_POST['output_template'];
     457        $options['auto_prefix'] = $_POST['auto_prefix'];
     458        $options['auto_suffix'] = $_POST['auto_suffix'];
     459        $options['auto_format'] = $_POST['auto_format'];
     460        $options['auto_output_template'] = $_POST['auto_output_template'];
    452461        $options['tag_weight'] = $_POST['tag_weight'];
    453462        $options['cat_weight'] = $_POST['cat_weight'];
     
    482491        $options['format'] = 'value';
    483492        $options['output_template'] = '<li>{link} ({strength})</li>';
     493        $options['auto_prefix'] = '<ul>';
     494        $options['auto_suffix'] = '</ul>';
     495        $options['auto_format'] = 'value';
     496        $options['auto_output_template'] = '<li>{link} ({strength})</li>';
    484497        $options['tag_weight'] = 1;
    485498        $options['cat_weight'] = 1;
     
    511524            <tr valign="top">
    512525                <th scope="row" align="right"><?php _e('Number of posts to show', 'similarity') ?>:</th>
    513                 <td><input name="limit" type="text" id="limit" value="<?php echo $options['limit']; ?>" size="2" /></td>
     526                <td colspan="2"><input name="limit" type="text" id="limit" value="<?php echo $options['limit']; ?>" size="2" /></td>
    514527            </tr>
    515528            <tr valign="top">
    516529                <th scope="row" align="right"><?php _e('Minimum match strength', 'similarity') ?>:</th>
    517                 <td><input name="minimum_strength" type="text" id="minimum_strength" value="<?php echo $options['minimum_strength']; ?>" size="5" /> <?php _e('(Any number between .00 and 1 with 1 being a perfect match.)', 'similarity') ?></td>
     530                <td colspan="2"><input name="minimum_strength" type="text" id="minimum_strength" value="<?php echo $options['minimum_strength']; ?>" size="5" /> <?php _e('(Any number between .00 and 1 with 1 being a perfect match.)', 'similarity') ?></td>
    518531            </tr>
    519532            <tr valign="top">
    520533
    521534                <th scope="row" align="right"><?php _e('Default display if no matches', 'similarity') ?>:</th>
    522                 <td><input name="none_text" type="text" id="none_text" value="<?php echo htmlspecialchars(stripslashes($options['none_text'])); ?>" size="40" /></td>
     535                <td colspan="2"><input name="none_text" type="text" id="none_text" value="<?php echo htmlspecialchars(stripslashes($options['none_text'])); ?>" size="40" /></td>
     536            </tr>
     537            <tr valign="top">
     538                <th scope="row" align="right"></th>
     539                <td align="center"><strong><?php _e('Template functions', 'similarity') ?></strong></td>
     540                <td align="center"><strong><?php _e('Auto display functions', 'similarity') ?></strong></td>
    523541            </tr>
    524542            <tr valign="top">
    525543                <th scope="row" align="right"><?php _e('Text and codes before the list', 'similarity') ?>:</th>
    526544                <td><input name="prefix" type="text" id="prefix" value="<?php echo htmlspecialchars(stripslashes($options['prefix'])); ?>" size="40" /></td>
     545                <td><input name="auto_prefix" type="text" id="auto_prefix" value="<?php echo htmlspecialchars(stripslashes($options['auto_prefix'])); ?>" size="40" /></td>
    527546            </tr>
    528547            <tr valign="top">
    529548                <th scope="row" align="right"><?php _e('Text and codes after the list', 'similarity') ?>:</th>
    530549                <td><input name="suffix" type="text" id="suffix" value="<?php echo htmlspecialchars(stripslashes($options['suffix'])); ?>" size="40" /></td>
     550                <td><input name="auto_suffix" type="text" id="auto_suffix" value="<?php echo htmlspecialchars(stripslashes($options['auto_suffix'])); ?>" size="40" /></td>
     551            </tr>
     552            <tr valign="top">
     553                <th scope="row" align="right"><?php _e('Output template', 'similarity') ?>:</th>
     554                <td><textarea name="output_template" id="output_template" rows="4" cols="32"><?php echo htmlspecialchars(stripslashes($options['output_template'])); ?></textarea></td>
     555                <td><textarea name="auto_output_template" id="auto_output_template" rows="4" cols="32"><?php echo htmlspecialchars(stripslashes($options['auto_output_template'])); ?></textarea></td>
     556            </tr>
     557            <tr valign="top">
     558                <th scope="row" align="right"></th>
     559                <td colspan="2" align="center"><?php _e('Valid template tags', 'similarity') ?>:{link}, {strength}, {url}, {title}</td>
    531560            </tr>
    532561            <tr valign="top">
    533562                <th scope="row" align="right"><?php _e('Display format for similarity strength', 'similarity') ?>:</th>
    534                 <td>
     563                <td colspan="2">
    535564                    <input type="radio" name="format" id="format" value="color"<?php if ($options['format'] == 'color') echo ' checked'; ?>><?php _e('Visual', 'similarity') ?></input>&nbsp;
    536565                    <input type="radio" name="format" id="format" value="percent"<?php if ($options['format'] == 'percent') echo ' checked'; ?>><?php _e('Percent', 'similarity') ?></input>&nbsp;
     
    541570            <tr valign="top">
    542571                <th scope="row" align="right"><?php _e('Custom text for strength', 'similarity') ?>:</th>
    543                 <td><input name="text_strong" type="text" id="text_strong" value="<?php echo htmlspecialchars(stripslashes($options['text_strong'])); ?>" size="40" /> &gt;75%</td>
     572                <td colspan="2"><input name="text_strong" type="text" id="text_strong" value="<?php echo htmlspecialchars(stripslashes($options['text_strong'])); ?>" size="40" /> &gt;75%</td>
    544573            </tr>
    545574            <tr valign="top">
    546575                <th scope="row" align="right">&nbsp;</th>
    547                 <td><input name="text_mild" type="text" id="text_mild" value="<?php echo htmlspecialchars(stripslashes($options['text_mild'])); ?>" size="40" /> 75% &gt; 50%</td>
     576                <td colspan="2"><input name="text_mild" type="text" id="text_mild" value="<?php echo htmlspecialchars(stripslashes($options['text_mild'])); ?>" size="40" /> 75% &gt; 50%</td>
    548577            </tr>
    549578            <tr valign="top">
    550579                <th scope="row" align="right">&nbsp;</th>
    551                 <td><input name="text_weak" type="text" id="text_weak" value="<?php echo htmlspecialchars(stripslashes($options['text_weak'])); ?>" size="40" /> 50% &gt; 25%</td>
     580                <td colspan="2"><input name="text_weak" type="text" id="text_weak" value="<?php echo htmlspecialchars(stripslashes($options['text_weak'])); ?>" size="40" /> 50% &gt; 25%</td>
    552581            </tr>
    553582            <tr valign="top">
    554583                <th scope="row" align="right">&nbsp;</th>
    555                 <td><input name="text_tenuous" type="text" id="text_tenuous" value="<?php echo htmlspecialchars(stripslashes($options['text_tenuous'])); ?>" size="40" /> &lt; 25%</td>
     584                <td colspan="2"><input name="text_tenuous" type="text" id="text_tenuous" value="<?php echo htmlspecialchars(stripslashes($options['text_tenuous'])); ?>" size="40" /> &lt; 25%</td>
    556585            </tr>
    557586            <tr valign="top">
    558587                <th scope="row" align="right"><?php _e('Relative mixing weights', 'similarity') ?>:</th>
    559                 <td><input name="tag_weight" type="text" id="tag_weight" value="<?php echo htmlspecialchars(stripslashes($options['tag_weight'])); ?>" size="40" /> <?php _e('Tags', 'similarity') ?></td>
     588                <td colspan="2"><input name="tag_weight" type="text" id="tag_weight" value="<?php echo htmlspecialchars(stripslashes($options['tag_weight'])); ?>" size="40" /> <?php _e('Tags', 'similarity') ?></td>
    560589            </tr>
    561590            <tr valign="top">
    562591                <th scope="row" align="right">&nbsp;</th>
    563                 <td><input name="cat_weight" type="text" id="cat_weight" value="<?php echo htmlspecialchars(stripslashes($options['cat_weight'])); ?>" size="40" /> <?php _e('Categories', 'similarity') ?></td>
    564             </tr>
    565             <tr valign="top">
    566                 <th scope="row" align="right"><?php _e('Output template', 'similarity') ?>:</th>
    567                 <td><textarea name="output_template" id="output_template" rows="4" cols="60"><?php echo htmlspecialchars(stripslashes($options['output_template'])); ?></textarea><br/><?php _e('Valid template tags', 'similarity') ?>:{link}, {strength}, {url}, {title}</td>
     592                <td colspan="2"><input name="cat_weight" type="text" id="cat_weight" value="<?php echo htmlspecialchars(stripslashes($options['cat_weight'])); ?>" size="40" /> <?php _e('Categories', 'similarity') ?></td>
    568593            </tr>
    569594            <tr valign="top">
    570595                <th scope="row" align="right"><?php _e('Show one more random related post', 'similarity') ?>:</th>
    571                 <td>
     596                <td colspan="2">
    572597                    <input type="radio" name="one_extra" id="one_extra" value="true"<?php if ($options['one_extra'] == 'true') echo ' checked'; ?>><?php _e('Yes', 'similarity') ?></input>&nbsp;
    573598                    <input type="radio" name="one_extra" id="one_extra" value="false"<?php if ($options['one_extra'] == 'false') echo ' checked'; ?>><?php _e('No', 'similarity') ?></input>&nbsp;
     
    577602            <tr valign="top">
    578603                <th scope="row" align="right"><?php _e('Auto-display list from function', 'similarity') ?>:</th>
    579                 <td>
     604                <td colspan="2">
    580605                    <input type="radio" name="adf" id="adf" value="none"<?php if ($options['adf'] == 'none') echo ' checked'; ?>><?php _e('None', 'similarity') ?></input>&nbsp;
    581606                    <input type="radio" name="adf" id="adf" value="tag"<?php if ($options['adf'] == 'tag') echo ' checked'; ?>>sim_by_tag</input>&nbsp;
     
    586611            <tr valign="top">
    587612                <th scope="row" align="right"><?php _e('Display Similarity on pages', 'similarity') ?>:</th>
    588                 <td>
     613                <td colspan="2">
    589614                    <input type="radio" name="sim_pages" id="sim_pages" value="yes"<?php if ($options['sim_pages'] == 'yes') echo ' checked'; ?>><?php _e('Yes', 'similarity') ?></input>&nbsp;
    590615                    <input type="radio" name="sim_pages" id="sim_pages" value="no"<?php if ($options['sim_pages'] == 'no') echo ' checked'; ?>><?php _e('No', 'similarity') ?></input>
Note: See TracChangeset for help on using the changeset viewer.