WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: WP SIMILE Timeline] Fix for Stablity Issues (3 posts)

  1. Erin B.
    Member
    Posted 4 years ago #

    1. Download the file at http://groups.google.com/group/wp-simile-timeline/web/options-timelin...
    2. Deactivate your plugin.
    3. Replace the old wp-simile-timeline / options / options-timeline.php
    file with the new one you just downloaded.
    4. Reactivate the plugin and enter your settings.

    Or, if you don't trust a blind PHP download, just erase the contents
    of that file and copy-paste the code below after reviewing it.

    I did not write the fix, so please don't ask me code-related
    questions. Someone sent this fix to me and I figured it might be
    useful for others. If anyone can get this to the developers and onto
    the WP plugins distro, I'm sure a lot of people would be really
    happy. Good luck all.

    ------------copy-the-code-below-this-line------------

    <?php
    /*
     * options-timeline.php
     * Description: WordPress Admin options for the SIMILE Timline Plugin
     * Plugin URI: http://www.freshlabs.de/journal/archives/2006/10/wordpress-plugin-sim...
     * Author: Tim Isenheim
     *
    
    ===========================================================================
            SIMILE Timeline for WordPress
            Copyright (C) 2006 Tim Isenheim
    
            This program is free software: you can redistribute it and/or modify
            it under the terms of the GNU General Public License as published by
            the Free Software Foundation, either version 3 of the License, or
            (at your option) any later version.
    
            This program is distributed in the hope that it will be useful,
            but WITHOUT ANY WARRANTY; without even the implied warranty of
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
            GNU General Public License for more details.
    
            You should have received a copy of the GNU General Public License
            along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    ===========================================================================
    */
    /*
    ---------------------------------------------------------------------------------
         This function saves user options selected in the Admin panel.
     *
    --------------------------------------------------------------------------------
    */
    function stl_update_options(){
            if (!isset($_POST) || !is_array($_POST) || sizeof($_POST) <= 0)
    return false;
            if(array_key_exists('stl_timeline_locale', $_POST)){
                    update_option('stl_timeline_locale', $_POST['stl_timeline_locale']);
            }
            if(array_key_exists('stl_timelinepageids', $_POST))
                    update_option('stl_timelinepageids', $_POST['stl_timelinepageids']);
            if(array_key_exists('stl_timeline_showfutureposts', $_POST))
                    update_option('stl_timeline_showfutureposts', $_POST
    ['stl_timeline_showfutureposts']);
            if(array_key_exists('stl_timeline_startdate', $_POST))
                    update_option('stl_timeline_startdate', $_POST
    ['stl_timeline_startdate']);
        if(array_key_exists('stl_timeline_linkhandling', $_POST))
                update_option('stl_timeline_linkhandling', $_POST
    ['stl_timeline_linkhandling']);
            $stl_band_options_to_save = array();
            if(array_key_exists('stl_timelineband_height', $_POST) &&
    array_key_exists('stl_timelineband_unit', $_POST) && array_key_exists
    ('stl_timelineband_interval', $_POST) &&
               array_key_exists('stl_band_bgcolor', $_POST) && array_key_exists
    ('stl_band_intvcolor', $_POST))
            {
            $stl_heights_posted = $_POST['stl_timelineband_height'];
            $stl_units_posted = $_POST['stl_timelineband_unit'];
            $stl_intervals_posted = $_POST['stl_timelineband_interval'];
            $stl_bgcolors_posted = $_POST['stl_band_bgcolor'];
            $stl_intvcolors_posted = $_POST['stl_band_intvcolor'];
            $stl_show_bandlabels = $_POST['stl_band_showlabels'];
            $stl_band_options_to_save["heights"] = stl_push_post_array("heights",
    $stl_heights_posted);
            $stl_band_options_to_save["units"] = stl_push_post_array("units",
    $stl_units_posted);
            $stl_band_options_to_save["intervals"] = stl_push_post_array
    ("intervals", $stl_intervals_posted);
            $stl_band_options_to_save["bgcolors"] = stl_push_post_array
    ("bgcolors", $stl_bgcolors_posted);
            $stl_band_options_to_save["intvalinecolors"] = stl_push_post_array
    ("intvalinecolors", $stl_intvcolors_posted);
            $stl_band_options_to_save["showbandlabels"] = stl_push_post_array
    ("showbandlabels", $stl_show_bandlabels);
            update_option('stl_timeline_band_options',
    $stl_band_options_to_save);
            }
            // Save timeline categories
            stl_edit_cats();
    }
    
    function stl_timeline_get_default_options(){
            $stl_timeline_default_options = array(
                    'stl_timeline_plugin_version' => STL_TIMELINE_PLUGIN_VERSION,
                    'stl_timelinepageids' => 0,
                    'stl_timelinecategories' => 1,
                    'stl_timeline_locale' => 'en',
                    'stl_timeline_showfutureposts' => 0,
                    'stl_timeline_startdate' => 0,
                    'stl_timeline_linkhandling' => 0,
                    'stl_timeline_band_options' => array(
                            "heights"            => array("70%","30%","0%","0%"),
                            "units"            => array("2","1","0","0"),
                            "intervals"            => array("200","100","0","0"),
                            "bgcolors"           => array("#eee","#ddd","#ccc","#aaa"),
                            "intvalinecolors"    => array("#aaa","#aaa","#aaa","#aaa"),
                            "showbandlabels"              => array("on", "off", "off", "off")
                    )
            );
            return $stl_timeline_default_options;
    
    }
    
    /*
    ---------------------------------------------------------------------------------
         Display User Options
     *
    --------------------------------------------------------------------------------
    */
    function stl_display_admin_page(){
            $stl_timelinepageids = get_option('stl_timelinepageids');
            $stl_timeline_showfutureposts = get_option
    ('stl_timeline_showfutureposts');
            $stl_timeline_locale = get_option('stl_timeline_locale');
            $stl_timeline_locales = array
    ("en","es","fr","it","ru","se","vi","zh");
            $stl_timeline_startdate = get_option('stl_timeline_startdate');
            $stl_timeline_linkhandling = get_option('stl_timeline_linkhandling');
    ?>
            <div class="wrap">
            <h2><?php _e('SIMILE Timeline Options', 'stl_timeline') ?></h2>
            <div id="stl-timeline-option-container">
        <ul id="stl-timeline-options-tabs">
            <li><a href="#stl-configuration"><span>Configuration</span></
    a></li>
            <li><a href="#stl-content"><span>Content</span></a></li>
                    <li><a href="#stl-design"><span>Design</span></a></li>
            <li><a href="#stl-documentation"><span>Documentation</span></
    a></li>
            <li><a href="#stl-credits"><span>Credits</span></a></li>
            <li><a href="#stl-uninstall"><span>Uninstall</span></a></li>
        </ul>
                    <form name="stl_options" method="post" action="options.php">
                    <?php wp_nonce_field('update-options'); ?>
                    <input type="hidden" name="action" value="update" />
    <!--
    ******************************************************
    Timeline Integration
    ******************************************************
    -->
                <div id="stl-configuration">
                    <fieldset class="options">
                            <h3>Timeline Configuration</h3>
                                    <table width="90%" cellpadding="8" class="form-table">
                                    <tr valign="middle">
                                    <th scope="row" style="width:340px"><?php _e('Pages with a
    timeline:', 'stl_timeline') ?><br /><small><?php _e('Enter the page or
    post IDs, seperated by comma. Set to 0 or all to include the Timeline
    script on all pages (default).', 'stl_timeline'); ?></small></th>
                                    <td><input name="stl_timelinepageids" type="text"
    id="stl_timelinepageids" value="<?php echo $stl_timelinepageids; ?>"
    size="30" />
                                    </td>
                                    </tr>
                                    <tr valign="middle">
                                    <th scope="row"><?php _e('Display future posts', 'stl_timeline') ?
    >:<br /><small><?php _e('Select this option if you want to show future
    
    posts in the timeline.', 'stl_timeline'); ?></small></th>
                                    <td>
                                    <fieldset>
                                    <label for="stl_timeline_showfutureposts">
                                    <input name="stl_timeline_showfutureposts"
    id="stl_timeline_showfutureposts" value="1" type="checkbox"<?php if
    ($stl_timeline_showfutureposts==1) echo ' checked="checked" '; ?> />
                                    <?php _e('Display future posts', 'stl_timeline'); ?></label><br />
                                    </fieldset>
                                    </td>
                                    </tr>
                                    <tr valign="middle">
                                    <th scope="row"><?php _e('Center timeline', 'stl_timeline') ?
    >:<br /><small><?php _e('Define where the timeline should be focused
    
    on load.<br />The default publish date will be used if the start or
    end date isn\'t set.', 'stl_timeline'); ?></small></th>
                                    <td>
                                    <fieldset>
                                    <label for="stl_timeline_startdate_cd">
                                    <input name="stl_timeline_startdate"
    id="stl_timeline_startdate_cd" value="0" type="radio"<?php if
    ($stl_timeline_startdate==0) echo ' checked="checked" '; ?> />
                                    <?php _e('Current date', 'stl_timeline'); ?></label><br />
                                    <label for="stl_timeline_startdate_fp">
                                    <input name="stl_timeline_startdate"
    id="stl_timeline_startdate_fp" value="1" type="radio"<?php if
    ($stl_timeline_startdate==1) echo ' checked="checked" '; ?> />
                                    <?php _e('Start date of first post', 'stl_timeline'); ?></
    label><br />
                                    <label for="stl_timeline_startdate_lp">
                                    <input name="stl_timeline_startdate"
    id="stl_timeline_startdate_lp" value="2" type="radio"<?php if
    ($stl_timeline_startdate==2) echo ' checked="checked" '; ?> />
                                    <?php _e('End date of last post', 'stl_timeline'); ?></label><br /
    
                                    <label for="stl_timeline_startdate_ct">
                                    <input name="stl_timeline_startdate"
    id="stl_timeline_startdate_ct" value="3" type="radio"<?php if
    ($stl_timeline_startdate==3) echo ' checked="checked" '; ?> />
                                    <?php _e('Center between first and last post', 'stl_timeline'); ?
    ></label>
    
                                    </fieldset>
                                    </td>
                                    </tr>
                                    <tr valign="middle">
                                    <th scope="row"><?php _e('Link Handling', 'stl_timeline') ?>:<br /
    ><small><?php _e('Sets whether clicking links from the timeline will
    
    open an info bubble or jump directly to the linked post.',
    'stl_timeline'); ?></small></th>
                                    <td>
                                    <fieldset>
                                    <label for="stl_timeline_handlelink_sb">
                                    <input name="stl_timeline_linkhandling"
    id="stl_timeline_handlelink_sb" value="0" type="radio"<?php if
    ($stl_timeline_linkhandling==0) echo ' checked="checked" '; ?> />
                                    <?php _e('Show info bubble', 'stl_timeline'); ?></label><br />
                                    <label for="stl_timeline_handlelink_dl">
                                    <input name="stl_timeline_linkhandling"
    id="stl_timeline_handlelink_dl" value="1" type="radio"<?php if
    ($stl_timeline_linkhandling==1) echo ' checked="checked" '; ?> />
                                    <?php _e('Jump to link location', 'stl_timeline'); ?></label>
                                    </fieldset>
                                    </td>
                                    </tr>
                                    <tr valign="middle">
                                    <th width="50%" scope="row"><?php _e('Localization:',
    'stl_timeline') ?><br /><small><?php _e('Timeline language. Still
    partially implemented at SIMILE.', 'stl_timeline'); ?></small></th>
                                    <td>
                                            <select name="stl_timeline_locale" id="stl_timeline_locale"
    style="width: 200px;">
                                            <?php foreach($stl_timeline_locales as $stl_locale) { ?>
                                                    <option value="<?php echo($stl_locale); ?>"<?php selected
    ($stl_locale, $stl_timeline_locale); ?>><?php echo($stl_locale); ?></
    option>
                                            <?php } ?>
                                            </select>
                                    </td>
                                    </tr>
                                    </table>
                                    <p class="submit"><input type="submit" class="button-secondary"
    name="Submit" value="<?php _e('Update Options', 'stl_timeline') ?>
    &raquo;" /></p>
                            </fieldset>
                </div>
    <!--
    ******************************************************
    Timeline Appearance
    ******************************************************
    -->
                            <div id="stl-design">
                            <fieldset class="options">
                            <h3><?php _e('Timeline Appearance', 'stl_timeline'); ?></h3>
                                    <p><?php _e('These options define the default timeline theme. To
    use a custom theme, use the parameter <a href="#stl-documentation"
    id="stl-documentation-link1"><code>theme</code></a> with the shortcode
    or template tag.', 'stl_timeline'); ?></p>
                                    <table width="100%" class="widefat">
                                    <thead>
                                    <tr>
                                            <th width="50%" valign="top">
                                            <?php _e('Upper Band', 'stl_timeline'); ?>
                                            </th>
                                            <th width="50%" valign="top">
                                            <?php _e('Lower Band', 'stl_timeline'); ?>
                                            </th>
                                    </tr>
                                    <tr>
                                            <td><?php stl_output_options_for_band(0); ?></td>
                                            <td><?php stl_output_options_for_band(1); ?></td>
                                    </table>
                                    <p class="submit"><input type="submit" name="Submit" value="<?php
    _e('Update Options', 'stl_timeline') ?> &raquo;" /></p>
                            </fieldset>
                            </div>
    <!--
    ******************************************************
    Timeline Categories
    ******************************************************
    -->
                            <div id="stl-content">
                            <fieldset class="options">
                            <h3><?php _e('Timeline Categories', 'stl_timeline'); ?></h3>
                                    <p><small><?php printf(__('Select the categories the Timeline
    should display.','stl_timeline') ); ?></small></p>
                                    <div id="colorPickerDiv" style="z-index:
    100;background:#eee;border:1px solid
    #ccc;position:absolute;visibility:hidden;"> </div>
                                    <?php stl_timeline_categories('category'); ?>
                                    <p class="submit"><input type="submit" name="Submit" value="<?php
    _e('Update Options', 'stl_timeline') ?> &raquo;" /></p>
                            </fieldset>
                            <fieldset class="options">
                            <h3><?php _e('Timeline Link Categories', 'stl_timeline'); ?></h3>
                                    <p><small><?php printf(__('Select the link-categories that hold
    your desired RSS links. The Timeline will display the feed
    content.','stl_timeline') ); ?></small></p>
                                    <div id="colorPickerDiv" style="z-index:
    100;background:#eee;border:1px solid
    #ccc;position:absolute;visibility:hidden;"> </div>
                                    <?php stl_timeline_categories('link_category'); ?>
                                    <p class="submit"><input type="submit" name="Submit" value="<?php
    _e('Update Options', 'stl_timeline') ?> &raquo;" /></p>
                            </fieldset>
                            </div>
    <!--
    ******************************************************
    Documentation
    ******************************************************
    -->
            <div id="stl-documentation">
                            <h3>Documentation</h3>
                            <div>
                            <h4><?php _e('Shortcode and Template Tag', 'stl_timeline') ?></h4>
                            <p>The simple thing first: There is just one template tag/
    shortcode. Both functions output the standard timeline for the
    categories and visuals set in the options panel.</p>
                            <ul>
                                    <li><code>[similetimeline]</code></li>
                                    <li><code><?php stl_simile_timeline(); ?></code></li>
                            </ul>
                            <h4><?php _e('Overriding automatic options', 'stl_timeline') ?></
    h4>
                            <p>If you want to display additional timelines with different
    content and design you can override the settings form the options
    panel by using parameters:</p>
                            <p>E.g. <code>[similetimeline cats="20,38,50" id="my-timeline"]</
    code> gives you the timeline with the DOM-ID "my-timeline" and loads
    content from categories 20, 38 and 50.</dt>
                            <h4><?php _e('Template Tag parameters', 'stl_timeline') ?></h4>
                            <dl>
                            <dt><code>cats</code> (Default: 0)</dt>
                                    <dd>Array of categories that you want to show in the timeline. Use
    comma-separated category-IDs for shortcode and an array for the PHP
    function.</dd>
                            <dt><code>id</code> (Default: 'stl-mytimeline')</dt>
                                    <dd>DOM-ID for the timeline container. E.g. "my-timeline"</dd>
                            <dt><code>scriptfile</code> (Default: 'timeline.js.php')</dt>
                                    <dd>Custom init file for the timeline JavaScript. Use the for the
    file in <samp>/wp-content/plugins/wp-simile-timeline/data/</samp>
    here.</dd>
                            <dt><code>theme</code>  (Default: 'dynamic-theme')</dt>
                                    <dd>This will set the CSS class for the timeline container,
    allowing you to set colors, fonts etc. in the timeline.css file. See
    the CSS file for a sample theme.</dd>
                            </dl>
                            <h4><?php _e('Event attributes (Custom post fields)',
    'stl_timeline') ?></h4>
                            <p>You can use these custom post fields to define individual
    attributes to a post:</p>
                            <dl>
                                    <dt><code>stl-icon</code></dt>
                                            <dd>URL to icon to be displayed in front of the timeline bar</dd>
                                    <dt><code>stl-image</code></dt>
                                            <dd>URL to image to be displayed inside the info bubble</dd>
                                    <dt><code>stl-link</code></dt>
                                            <dd>Defines a custom link for the title inside the timeline info
    bubble</dd>
                                    <dt><code>stl-tapeImage</code></dt>
                                            <dd>URL to image for a repating background image on event tapes</
    dd>
                                    <dt><code>stl-caption</code></dt>
                                            <dd>Hover info text for event tapes</dd>
                                    <dt><code>stl-classname</code></dt>
                                            <dd>CSS class name to highlight special events with custom CSS
    rules</dd>
                            </dl>
                            </div>
            </div>
    <!--
    ******************************************************
    Credits
    ******************************************************
    -->
            <div id="stl-credits">
                    <h3><?php _e('Credits', 'stl_timeline'); ?></h3>
                    <p><?php _e('Special thanks to these people, organisations and
    projects. Without them, this plugin wouldn\'t be possible',
    'stl_timeline'); ?>:</p>
                    <dl>
                            <dt><a href="http://simile.mit.edu/">SIMILE Project</a></dt>
                                    <dd>for providing the Timeline script API and releasing useful,
    semantic applications.</dd>
                            <dt><a href="http://phplens.com/phpeverywhere/
    adodb_date_library">John Lim of PHP Everywhere</a></dt>
                                    <dd>for creating the ADOdb Date Library, making date formatting
    with dates before 1970 a charm.</dd>
                            <dt><a href="http://www.freshlabs.de/journal/archives/2006/10/
    wordpress-plugin-simile-timeline/#comments">My blog commenters</a></
    dt>
                                    <dd>for giving me helpful bug feedback and inspiration for new
    features.</dd>
                    </dl>
            </div>
    
    <!--
    ******************************************************
    Uninstall
    ******************************************************
    -->
            <div id="stl-uninstall">
    
                    <fieldset class="options">
                            <h3>Uninstall plugin</h3>
                                    <p>
                                    <?php
                                    _e("With this option you can remove all database entries related
    to this plugin.", 'stl_timeline');
                                    echo '<br />';
                                    _e("This might also work as re-initialization in case of
    unexpected behavior.", 'stl_timeline');
                                    echo '<br />';
                                    _e("The plugin will be deactivated after all plugin-related data
    has been removed.", 'stl_timeline');
                                    ?></p>
                                    <p><?php _e("Sorry to hear that you have to do that for whatever
    reasons.", 'stl_timeline'); ?></p>
    
                                    <p>
                                    <input type="submit" id="stl-delete-plugindata-button"
    value="Delete Data" class="submitdelete">
                                    <input type="checkbox" name="delete-action" id="stl-timeline-
    delete-confirm" value="purgedb" /> <label for="stl-timeline-delete-
    confirm">Yes, please purge plugin database entries</label>
                                    </p>
                    </fieldset>
            </div>
    
            </form>
    <!--
    ******************************************************
    ******************************************************
    -->
            </div><!-- #stl-stimeline-options-container -->
            </div><!-- .wrap -->
    <?php
    
    }
    
    /*
    ---------------------------------------------------------------------------------
     * set categories to display in the timeline
     *
    --------------------------------------------------------------------------------
    */
    function stl_timeline_categories($term_type='category') {
    
        global $wpdb;
        global $cat_timeline;
            global $wp_roles;
    
            if ( current_user_can('manage_categories') ) {  ?>
    
            <table width="100%" cellpadding="3" cellspacing="3" class="widefat">
                    <thead>
                    <tr>
                    <th scope="col" style="width:120px;text-align:center;"><?php
    _e('Show in Timeline?', 'stl_timeline') ?></th>
                    <th scope="col" style="width:60px;"><?php _e('ID',
    'stl_timeline') ?></th>
                    <th scope="col" align="left" class="row-title"><?php _e
    ('Name', 'stl_timeline') ?></th>
                    <th scope="col" width="130" align="center"><?php _e('Color',
    'stl_timeline') ?></th>
                    </tr>
                </thead>
    <?php stl_cat_rows($term_type); ?>
            </table>
    
    <?php
            }
    
    }
    
    /*
    ---------------------------------------------------------------------------------
     * output category ids, names and checkboxes
     *
    --------------------------------------------------------------------------------
    */
    function stl_cat_rows($term_type, $parent = 0, $level = 0, $categories
    = 0, $termdata=null) {
    
        global $wpdb, $class;
        global $cat_timeline;
    
            $table = $wpdb->prefix."stl_timeline_terms";
            // read all categories from database if none is set in the parameter
            if(!$termdata){
                    $terms = get_terms($term_type, array('hide_empty'=>false));
            }
            else{
                    $terms = $termdata;
            }
    
            if ($terms) {
                    $index = 1;
                    $i=0;
                    foreach ($terms as $category) {
                            if ($category->parent == $parent) {
                                    $category->name = wp_specialchars($category->name);
                                    $pad = str_repeat('— ', $level);
                                    $catid = $category->term_id;
                                    $cat = $wpdb->get_row("SELECT active, color FROM $table WHERE
    term_id = $catid;");
                                    if ( current_user_can('manage_categories') ) {
                                            if ($cat->active ) $catvis_timelined = 'checked="checked"'; else
    $catvis_timelined = "";
                                            $edit  = "<label for='timelined_" . $catid . "'>".__('enable',
    'stl_timeline')."</label> <input name='stl-timelined[$catid]'
    id='timelined_" . $catid . "' class='edit' type='checkbox'
    $catvis_timelined />&nbsp;&nbsp;";
    
                                            $color = stl_colorpick_unit('stl-catcolor',$catid, 'pick'.$catid,
    $cat->color);
                                    } else
                                            $edit = '';
                                    $class = ('alternate' == $class) ? '' : 'alternate';
                                    echo "<tr class='$class'>";
                                    echo '<th style="text-align: center;" class="">'.$edit.'</
    th>';  // TODO: class="check-column"
                                    echo '<th scope="row">'.$category->term_id.'</th>';
                                    echo "<th class=\"row-title\">$pad ".$category->name."</th>
                                            <th style='text-align: center;'>$color</th>
                                            </tr>" . "\n";
                                    stl_cat_rows($term_type, $catid, $level + 1, $categories, $terms);
                                    $index += 2;
                            }
                            $i++;
                    }
            } else {
                    return false;
            }
    
    }
    
    /*
    ---------------------------------------------------------------------------------
     * build markup for colorpicker
     *
    --------------------------------------------------------------------------------
    */
    function stl_colorpick_unit($field, $id, $palette, $hexvalue){
            $onclick = 'onclick="cp.select(document.getElementById(\''.$field.'_'.
    $id.'\'), \''.$palette.'\');return false;" ';
            $attribs = 'style="background: '.$hexvalue.';" class="stl-colorfield"
    name="' . $palette . '" id="' . $palette .'"';
            $link = '<a href="#"' . $onclick . $attribs .'><span>Pick color</
    span></a>' . "\n";
            $input = '              <input type="text" class="stl-colorvalue" value="'.
    $hexvalue.'" size="7" id="' . $field . '_' . $id. '" name="' .
    $field . '['.$id.']" />';
            return $link . $input;
    
    }
    
    /*
    ---------------------------------------------------------------------------------
     * update categories that are display by the timeline
     *
    --------------------------------------------------------------------------------
    */
    function stl_edit_cats() {
    
        global $wpdb;
        global $cat_timeline;
        $categories='';
    
            if (!isset($_POST) || !is_array($_POST) || sizeof($_POST) <= 0)
    return false;
            if (!array_key_exists('stl-catcolor', $_POST) || !is_array($_POST
    ["stl-catcolor"])) return false;
    
            if (!$categories)
                    $categories = $wpdb->get_results("SELECT * FROM ".$wpdb-
    
    >prefix."stl_timeline_terms");
    
            if ($categories) {
                    $stl_cs = array();
                    foreach ($categories as $category) {
                            $active = 0;
    
                            # save category color to database
                            if (!empty($_POST["stl-catcolor"][$category->term_id])){
                                    stl_timeline_update_catcolor($category->term_id, $_POST["stl-
    catcolor"][$category->term_id]);
                            }
                            # save active state to database
                            if ( isset($_POST['stl-timelined'][$category->term_id])) {
                                    array_push($stl_cs, $category->term_id);
                                    // Update category active/inactive
                                    stl_timeline_update_catactive($category->term_id, 1);
                            } else {
                                    stl_timeline_update_catactive($category->term_id, 0);
                            }
                    }
                    // save categories as CSV to option table
                    $stl_cs_string = implode(",", $stl_cs);
                    update_option('stl_timelinecategories', $stl_cs_string);
            }
    
    }
    
    function __stl_active_select($index, $cmp){
            if($index == $cmp){
                    $s = ' value="'.$index.'" selected="selected"';
            }
            else{
                    $s = ' value="'.$index.'"';
            }
            return $s;
    
    }
    
    /*
    ---------------------------------------------------------------------------------
         Output option interface for Timeline bands
     *
    --------------------------------------------------------------------------------
    */
    function stl_output_options_for_band($band_id){
            $bandoptions = get_option('stl_timeline_band_options');
            $show_labels_checked = '';
            if($bandoptions["showbandlabels"][$band_id] == "on"):
                    $show_labels_checked = 'checked="checked"';
            endif;
            ?>
            <table width="100%" cellpadding="0" cellspacing="0">
                    <tr class="alternate">
                            <td><label><?php _e('Height in % or px (add unit)',
    'stl_timeline'); ?></label></td>
                            <td><input name="<?php echo "stl_timelineband_height[$band_id]"; ?
    >" type="text" id="<?php echo "stl_timelineband_height_".$band_id; ?>"
    
    value="<?php echo $bandoptions["heights"][$band_id]; ?>" size="10" /></
    td>
                    </tr>
                    <tr>
                            <td><label><?php _e('Resolution', 'stl-timeline'); ?></label></td>
                            <td>
                            <select name="<?php echo "stl_timelineband_unit[$band_id]"; ?>"
    type="text" id="<?php echo "stl_timelineband_unit_".$band_id; ?>">
                            <option<?php echo __stl_active_select(0, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Millisecond', 'stl_timeline'); ?></option>
                            <option<?php echo __stl_active_select(1, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Second', 'stl_timeline'); ?></option>
                            <option<?php echo __stl_active_select(2, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Minute', 'stl_timeline'); ?></option>
                            <option<?php echo __stl_active_select(3, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Hour', 'stl_timeline'); ?></option>
                            <option<?php echo __stl_active_select(4, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Day', 'stl_timeline'); ?></option>
                            <option<?php echo __stl_active_select(5, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Week', 'stl_timeline'); ?></option>
                            <option<?php echo __stl_active_select(6, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Month', 'stl_timeline'); ?></option>
                            <option<?php echo __stl_active_select(7, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Year', 'stl_timeline'); ?></option>
                            <option<?php echo __stl_active_select(8, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Decade', 'stl_timeline'); ?></option>
                            <option<?php echo __stl_active_select(9, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Century', 'stl_timeline'); ?></option>
                            <option<?php echo __stl_active_select(10, $bandoptions["units"]
    [$band_id]); ?>><?php _e('Millenium', 'stl_timeline'); ?></option>
                            </select>
                            </td>
                    </tr>
                    <tr class="alternate">
                            <td><label><?php _e('Interval size', 'stl-timeline'); ?></label></
    td>
                            <td><input name="<?php echo "stl_timelineband_interval[$band_id]"; ?
    >" type="text" id="<?php echo "stl_timelineband_interval_".$band_id; ?
    >" value="<?php echo $bandoptions["intervals"][$band_id]; ?>"
    
    size="10" /> px</td>
                    </tr>
                    <tr>
                            <td><label><?php _e('Background color', 'stl_timeline'); ?></
    label></td>
                            <td><?php echo stl_colorpick_unit('stl_band_bgcolor',
    $band_id,'stl_band'.$band_id.'_cp_bg',$bandoptions["bgcolors"]
    [$band_id]); ?></td></tr>
                    <tr class="alternate">
                            <td><label><?php _e('Interval line color', 'stl_timeline'); ?></
    label></td>
                            <td><?php echo stl_colorpick_unit('stl_band_intvcolor',
    $band_id,'stl_band'.$band_id.'_cp_intline',$bandoptions
    ["intvalinecolors"][$band_id]); ?></td></tr>
                    <tr>
                            <td><label for="<?php echo "stl_band_showlabels_".$band_id; ?>"><?
    php _e('Show Labels', 'stl_timeline'); ?></label></td>
                            <td><input type="checkbox" name="<?php echo "stl_band_showlabels
    [$band_id]"; ?>" id="<?php echo "stl_band_showlabels_".$band_id; ?>" <?
    php echo $show_labels_checked; ?> /></td>
                    </tr>
            </table>
    <?php
    
    }
    
    /*
    ---------------------------------------------------------------------------------
         Push options from $_POST array in 2-D array element defined by
    $key
     *
    --------------------------------------------------------------------------------
    */
    function stl_push_post_array($key, $post_arr){
            $response = array();
            for($i=0; $i<sizeof($post_arr); $i++){
            $bop = $post_arr[$i];
            if(!empty($bop)){
                    $response[$i] = $bop;
            }
            else{
                    $default = get_option('stl_timeline_band_options');
                    $response[$i] = $default[$key][$i];
            }
            }
         return $response;
    }
    
    ?>
  2. Erin B.
    Member
    Posted 4 years ago #

  3. Erin B.
    Member
    Posted 4 years ago #

    gee. okay. how about this one:

    http://groups.google.com/group/wp-simile-timeline/files?hl=en

    look for the file called: options-timeline.php

Topic Closed

This topic has been closed to new replies.

About this Topic