WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Update for 3.5.1

[Resolved] Update for 3.5.1

  • Don’t know how to contact author; but was able to get this working on my WordPress 3.5.1 w/ Debian squeeze.

    libgv-php5 was enabled via:

    apt-get install libgv-php5
    echo “extension=gv.so” > /etc/php5/conf.d/graphviz.ini

    Patch included:

    diff –git a/tfo-graphviz-admin.php b/tfo-graphviz-admin.php
    index 6ae1dfd..1985233 100644
    — a/tfo-graphviz-admin.php
    +++ b/tfo-graphviz-admin.php
    @@ -146,7 +146,7 @@ class TFO_Graphviz_Admin extends TFO_Graphviz {
    exec( $exec, $out, $r );
    $message .= “<h4>Command run:</h4>\n”;
    $message .= “<div class=’pre’>$exec</div>\n”;
    – $out = preg_replace( ‘/tex_.+?\.log/i’, ‘test.log‘, join(“\n”, $out));
    + $out = preg_replace( ‘/tex_.+?\.log/i’, ‘test.log‘, join(“\n”, $out));
    $message .= “<h4>Result:</h4>\n”;
    $message .= “<div class=’pre’>$out</div>\n”;
    $message .= “<p>Exit code: $r</p>\n”;
    @@ -161,8 +161,8 @@ class TFO_Graphviz_Admin extends TFO_Graphviz {
    $url = content_url( TFO_GRAPHVIZ_CONTENT.’/test.png’ ) . “?” . mt_rand();
    }
    @unlink(TFO_GRAPHVIZ_CONTENT_DIR.’/test.log’);
    – $alt = attribute_escape( __( ‘Test Image’, ‘tfo-graphviz’ ) );
    – echo “<img class=’test-image’ src='” . clean_url( $url ) . “‘ alt=’$alt’ />\n”;
    + $alt = esc_attr( __( ‘Test Image’, ‘tfo-graphviz’ ) );
    + echo “<img class=’test-image’ src='” . esc_url( $url ) . “‘ alt=’$alt’ />\n”;
    echo “<p class=’test-image’>” . __( ‘If you can see a graph then all is well.’, ‘tfo-graphviz’ ) . ‘</p>’;
    $r = true;
    }
    @@ -224,7 +224,7 @@ tr.tfo-graphviz-method-<?php echo $current_method; ?> {
    $available_methods[$class] = $method;
    if(‘TFO_Graphviz_Remote’ == $class)
    continue;
    – $graphviz_object = new $class(‘a->b;’, array(id=>’admin’,simple=>true));
    + $graphviz_object = new $class(‘a->b;’, array(‘id’=>’admin’,’simple’=>true));
    }
    unset( $class, $method, $graphviz_object );

    @@ -256,7 +256,7 @@ tr.tfo-graphviz-method-<?php echo $current_method; ?> {

    <?php if ( empty( $errors ) ) $this->test_image(); ?>

    – <form action=”<?php echo clean_url( remove_query_arg( ‘updated’ ) ); ?>” method=”post”>
    + <form action=”<?php echo esc_url( remove_query_arg( ‘updated’ ) ); ?>” method=”post”>

    <table class=”form-table”>
    <tbody>
    @@ -288,7 +288,7 @@ tr.tfo-graphviz-method-<?php echo $current_method; ?> {

    <tr class=”tfo-graphviz-path tfo-graphviz-method tfo-graphviz-method-graphviz <?php if ( in_array( ‘graphviz_path’, $errors ) ) echo ‘ form-invalid’; ?>”>
    <th scope=”row”><label for=”tfo-graphviz-graphviz-path”><?php _e( ‘graphviz path’ ); ?></label></th>
    – <td><input type=’text’ name=’tfo-graphviz[graphviz_path]’ value='<?php echo attribute_escape( $values[‘graphviz_path’] ); ?>’ id=’tfo-graphviz-graphviz-path’ /><?php
    + <td><input type=’text’ name=’tfo-graphviz[graphviz_path]’ value='<?php echo esc_attr( $values[‘graphviz_path’] ); ?>’ id=’tfo-graphviz-graphviz-path’ /><?php
    if ( !$this->options[‘graphviz_path’] ) {
    $guess_graphviz_path = trim( @exec( ‘which dot’ ) );
    if ( $guess_graphviz_path && file_exists( $guess_graphviz_path ) )
    @@ -301,13 +301,13 @@ tr.tfo-graphviz-method-<?php echo $current_method; ?> {

    <tr class=”tfo-graphviz-path tfo-graphviz-method tfo-graphviz-method-remote <?php if ( in_array( ‘graphviz_remote_key’, $errors ) ) echo ‘ form-invalid’; ?>”>
    <th scope=”row”><label for=”tfo-graphviz-remote-key”><?php _e( ‘Remote TFO Graphviz API key (blank or invalid keymeans “free” mode)’ ); ?></label></th>
    – <td><input type=’text’ name=’tfo-graphviz[remote_key]’ value='<?php echo attribute_escape( $values[‘remote_key’] ); ?>’ size=’64’ id=’tfo-graphviz-remote-key’ /><?php
    + <td><input type=’text’ name=’tfo-graphviz[remote_key]’ value='<?php echo esc_attr( $values[‘remote_key’] ); ?>’ size=’64’ id=’tfo-graphviz-remote-key’ /><?php
    ?></td>
    </tr>

    <tr class=”tfo-graphviz-maxage<?php if ( in_array( ‘graphviz_maxage’, $errors ) ) echo ‘ form-invalid’; ?>”>
    <th scope=”row”><label for=”tfo-graphviz-maxage”><?php _e(‘Maximum age, in days, of generated content (enter 0 to disable expiration)’); ?></label></th>
    – <td><input type=’text’ name=’tfo-graphviz[maxage]’ value='<?php echo attribute_escape( $values[‘maxage’] ); ?>’ id=’tfo-graphviz-maxage’ /></td>
    + <td><input type=’text’ name=’tfo-graphviz[maxage]’ value='<?php echo esc_attr( $values[‘maxage’] ); ?>’ id=’tfo-graphviz-maxage’ /></td>
    </tr>

    </tbody>
    @@ -315,7 +315,7 @@ tr.tfo-graphviz-method-<?php echo $current_method; ?> {

    <p class=”submit”>
    – <input type=”submit” class=”button-primary” value=”<?php echo attribute_escape( __( ‘Update TFO Graphviz Options’, ‘tfo-graphviz’ ) ); ?>” />
    + <input type=”submit” class=”button-primary” value=”<?php echo esc_attr( __( ‘Update TFO Graphviz Options’, ‘tfo-graphviz’ ) ); ?>” />
    <?php wp_nonce_field( ‘tfo-graphviz’ ); ?>
    </p>
    </form>
    diff –git a/tfo-graphviz-graphviz.php b/tfo-graphviz-graphviz.php
    index 67765a8..f43c5af 100644
    — a/tfo-graphviz-graphviz.php
    +++ b/tfo-graphviz-graphviz.php
    @@ -69,7 +69,7 @@ class TFO_Graphviz_Graphviz extends TFO_Graphviz_Method {
    1 => array(‘pipe’, ‘w’),
    2 => array(‘file’, ‘/dev/null’, ‘w’),
    );
    – $pipes = undef;
    + $pipes = array();
    $proc = proc_open($cmd, $ds, $pipes, ‘/tmp’, array());
    if(is_resource($proc)) {
    fwrite($pipes[0], $this->dot);
    @@ -114,7 +114,7 @@ class TFO_Graphviz_Graphviz extends TFO_Graphviz_Method {
    $mapfile = “$this->img_path_base/$hash.map”;
    if (is_super_admin() || !file_exists($imgfile) || ($this->imap && !file_exists($mapfile))) {
    $ret = $this->process_dot($imgfile, $mapfile);
    – if ( is_wp_error( $file ) ) {
    + if ( is_wp_error( $ret ) ) {
    $this->error =& $ret;
    return $this->error;
    }
    diff –git a/tfo-graphviz-method.php b/tfo-graphviz-method.php
    index bbfe32d..01a1e5b 100644
    — a/tfo-graphviz-method.php
    +++ b/tfo-graphviz-method.php
    @@ -14,7 +14,7 @@ class TFO_Graphviz_Method {
    function __construct($dot, $atts) {
    $this->dot = (string) $dot;
    foreach(array(‘id’, ‘lang’, ‘simple’, ‘output’, ‘href’, ‘imap’, ‘title’) as $att) {
    – if($atts[$att]) $this->$att = $atts[$att];
    + if(array_key_exists($att, $atts)) $this->$att = $atts[$att];
    }
    $this->url = false;
    }
    diff –git a/tfo-graphviz.php b/tfo-graphviz.php
    index 4773dc5..8c6b5e2 100644
    — a/tfo-graphviz.php
    +++ b/tfo-graphviz.php
    @@ -121,13 +121,13 @@ class TFO_Graphviz {
    else $e .= ‘.’;
    return $e;
    }
    – $url = clean_url($gv->url());
    + $url = esc_url($gv->url());
    $href = $gv->href;
    if($href) {
    if(strtolower($href) == ‘self’) $href = $url;
    – else $href = clean_url($href);
    + else $href = esc_url($href);
    }
    – $alt = attribute_escape(is_wp_error($gv->error) ? $gv->error->get_error_message() . “: $gv->dot” : $gv->title);
    + $alt = esc_attr(is_wp_error($gv->error) ? $gv->error->get_error_message() . “: $gv->dot” : $gv->title);

    $ret = “<img src=\”$url\” class=\”graphviz\””;
    if(!empty($alt)) $ret .= ” alt=\”$alt\” title=\”$alt\””;
    @@ -147,7 +147,7 @@ class TFO_Graphviz {
    }

    // Validate atts
    – $atts[‘id’] = attribute_escape($atts[‘id’]);
    + $atts[‘id’] = esc_attr($atts[‘id’]);
    if($atts[‘lang’] && !in_array($atts[‘lang’], $this->langs)) {
    $this->err = “Unknown lang: “.$atts[‘lang’];
    return false;

    http://wordpress.org/extend/plugins/tfo-graphviz/

Viewing 1 replies (of 1 total)
  • Thanks for patching this plugin. I have really been wanting to have graphviz working in WordPress. This is a great effort.

    Is it possible for you to email the patch to me? I know you have put the diff output above, but have you posted the patched file somewhere?

    Cheers,

    Brad

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Update for 3.5.1’ is closed to new replies.