Plugin Directory

Changeset 208464


Ignore:
Timestamp:
02/20/2010 11:42:49 PM (16 years ago)
Author:
vincenzodb
Message:
 
Location:
meemi-in-wordpress/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • meemi-in-wordpress/trunk/inc/meemi_comment.php

    r177474 r208464  
    3131## GET LAST MEME FOR MEMI COMMENT
    3232class MeemiLastMeme {
     33
     34    function startElement($parser, $tagName, $attrs) {
     35        if ($this->insideitem) {
     36            $this->tag = $tagName;
     37        } elseif ($tagName == "MEME") {
     38            $this->insideitem = true;
     39            $this->meme_id = $attrs['ID'];         
     40        }
     41    }
     42
     43    function endElement($parser, $tagName) {
     44        if ($tagName == "MEME") {
     45            $id_meme = $this->meme_id;
     46           
     47            global $wpdb;
     48            $table_name = $wpdb->prefix . "tb_meemi_comment";
     49            $last_id = $wpdb->get_var("SELECT COUNT(*) FROM $table_name;");
     50                       
     51            $update = "UPDATE ".$table_name." SET id_meme = '$id_meme' WHERE id = '$last_id'";
     52            $wpdb->query($update);
     53           
     54            $this->meme_id = "";
     55            $this->insideitem = false;
     56           
     57        }   
     58    }
     59
     60    function characterData($parser, $data) {
     61        if ($this->insideitem) {
     62           
     63            switch ($this->tag) {
     64                case "MEME":
     65                    $this->meme_id .= $data;
     66                break;
     67            }
     68         }
     69    }
     70}
     71
     72## UPDATE MEME ID FOR  MEEMI COMMENTS
     73class MeemiUpdateMeme {
    3374
    3475    function startElement($parser, $tagName, $attrs) {
     
    207248}   
    208249
     250
     251function clean_caption($string){
     252    $stringa = "";
     253    preg_match_all('/[caption ([a-z A-Z \" - _ =])/', $string, $matches);
     254    foreach ($matches as $text) {
     255        // Provides: <body text='black'>
     256        $stringa = str_replace($text, " ", $stringa);
     257    }
     258
     259    return $stringa;
     260}
     261
     262
     263
    209264## PARSE STRING OF MEMI COMMENT FOR CHAN AND USERS
    210265function parse_meemi_comment($stringa, $nome) {
  • meemi-in-wordpress/trunk/meemi_in_wordpress_3.php

    r181314 r208464  
    55Plugin URI: http://vincenzodibiaggio.net/tech/meemi-in-wordpress/
    66Description: Plugin to display your meme (http://meemi.com/) on your blog and to send your post to Meemi. Work with 2.7.1 to 2.8.x
    7 Version: 3.0.1
     7Version: 3.0.2
    88Author: Enrico Scognamillo e Vincenzo Di Biaggio
    99Author URI: http://www.vincenzodibiaggio.net/tech
     
    103103    }
    104104}
    105 #####################
    106 
     105
     106############################################################# MEEMI CONTENT
     107include('inc/meemi_content.php');
    107108############################################################# BEGIN MEEMI COMMENT
    108109include('inc/meemi_comment.php');
     
    249250            echo '<tr valign="top">';
    250251            echo '<th scope="row">Password</th>';
    251             echo '<td><input type="text" name="meemi_pwd" value="'.get_option('meemi_pwd').'" /></td>';
     252            echo '<td><input type="password" name="meemi_pwd" value="'.get_option('meemi_pwd').'" /></td>';
    252253            echo '</tr>';
    253254           
     
    408409        $loc = $user->info['location'];
    409410       
    410         echo "<p>".__('Il mio Screen Name &egrave;','meemi_in_wordpress_3')." ".$sname.". ".__('seguo','meemi_in_wordpress_3')." ".$n_following." Meemers, ".$n_followers." ".__('mi seguono.','meemi_in_wordpress_3')."<br/> ".__('Il mio vero nome &egrave;','meemi_in_wordpress_3')." ".$rname." ".__('e sono a','meemi_in_wordpress_3')." ".$loc."</p>\n";
     411        echo "<p>".__('Il mio Screen Name &egrave;','meemi_in_wordpress_3')." ".$sname.". ".__('seguo','meemi_in_wordpress_3')." ".$n_following." Meemers, ".$n_followers." ".__('mi seguono.','meemi_in_wordpress_3')."<br/> ".__('Il mio vero nome &egrave;','meemi_in_wordpress_3')." ".$rname." ".__('e sono ','meemi_in_wordpress_3')." ".$loc."</p>\n";
    411412       
    412413        echo "<p><a href=\"http://meemi.com/".$sname."/profile\" target=\"_blank\" title=\"Il mio profilo su Meemi\">".__('Visita il mio profilo su Meemi','meemi_in_wordpress_3')."</a></p>";
     
    514515
    515516function send_to_meemi($post_ID) {
     517global $wpdb;
    516518    $meemi_screen_name = get_option('meemi_screen_name');
    517519    $meemi_pwd = get_option('meemi_pwd');
     
    524526    $posted = get_post($post_ID);
    525527    $thispostlink = get_permalink($post_ID);
    526        
    527528    $categories = get_the_category($posted->ID);
     529    $authorId = $posted->post_author;
     530    $author_nickname = $wpdb->get_var($wpdb->prepare("SELECT user_nicename FROM $wpdb->users WHERE ID = '$authorId' LIMIT 1"));
     531   
    528532    $chan = "";
    529533    $imeemi = 0;
     
    560564                "&channels=".$chan.", ".$meemi_blog_chan.
    561565                "&location=".$meemi_location.
    562                 "&text_content=[b]".$posted->post_title.'[/b] - '.$content_to_send.
     566                "&text_content=[b]".$posted->post_title."[/b]\n\n ".$content_to_send."\n\n[i]By: ".$author_nickname."[/i]".
    563567                "&"); // add POST fields
    564568            $result = curl_exec($ch); // run the whole process
     
    592596            # END MEEMI COMMENT
    593597        }
    594     // post update - Non attivo meemi post, non serve
    595     }elseif ($posted->post_date != $posted->post_modified and $posted->post_status == "publish" ) {
    596         if ( $_REQUEST['aggiorna_meemi_post'] == "true" ) {
    597            
     598    // resend post to meemi             
     599    }elseif ( $posted->post_date != $posted->post_modified and $posted->post_status == "publish" and $_POST['reinvia_meemi_post'] == "true" ) {
    598600            if($meemi_content == "part") {
     601                $content_to_send = clean_caption($content_to_send);
    599602                $content_to_send = substr(strip_tags($posted->post_content),0,400);
    600603            }else {
     
    616619                "&channels=".$chan.", ".$meemi_blog_chan.
    617620                "&location=".$meemi_location.
    618                 "&text_content=[i]".__('Ho aggiornato il post:','meemi_in_wordpress_3')." [/i] - [b]".$posted->post_title."[/b] - ".__('Leggilo qui:','meemi_in_wordpress_3')." ".$thispostlink.
     621                "&text_content=[b]".$posted->post_title."[/b]\n\n ".$content_to_send."\n\n[i]By: ".$author_nickname."[/i]".
    619622                "&"); // add POST fields
    620623            $result = curl_exec($ch); // run the whole process
    621624
     625            curl_close($ch); 
     626           
     627            # MEEMI COMMENT
     628            $meemi_comment = get_option('meemi_comment');
     629            if ($meemi_comment == "true") {
     630               
     631                global $wpdb;
     632                $table_name = $wpdb->prefix . "tb_meemi_comment";
     633                $insert_meme = "UPDATE ".$table_name." (id_post, id_meme) VALUES ('$post_ID', '00')";
     634                $wpdb->query($insert_meme);
     635               
     636                $xml_parser = xml_parser_create();
     637                $meemi_parser = new MeemiUpdateMeme();
     638                xml_set_object($xml_parser,$meemi_parser);
     639                xml_set_element_handler($xml_parser, "startElement", "endElement");
     640                xml_set_character_data_handler($xml_parser, "characterData");     
     641               
     642                $screen_name = get_option('meemi_screen_name');
     643                $fp = fopen("http://meemi.com/api/".$screen_name."/c-".$meemi_blog_chan."/limit_1","r");
     644       
     645                while ($data = fread($fp, 100))
     646                xml_parse($xml_parser, $data, feof($fp));
     647
     648                fclose($fp);
     649                xml_parser_free($xml_parser);
     650            }
     651            # END MEEMI COMMENT
     652    // post update - Non attivo meemi post, non serve
     653    }elseif ($posted->post_date != $posted->post_modified and $posted->post_status == "publish" ) {
     654        if ( $_REQUEST['aggiorna_meemi_post'] == "true" ) {
     655           
     656            if($meemi_content == "part") {
     657                $content_to_send = clean_caption($content_to_send);
     658                $content_to_send = substr(strip_tags($posted->post_content),0,400);
     659            }else {
     660                $content_to_send = strip_tags($posted->post_content);
     661            }
     662           
     663            $ch = curl_init();    // initialize curl handle
     664            curl_setopt($ch, CURLOPT_URL,"http://meemi.com/api/".$meemi_screen_name."/save"); // set url to post to
     665            curl_setopt($ch, CURLOPT_FAILONERROR, 1);
     666            curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
     667            curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
     668            curl_setopt($ch, CURLOPT_POST, 1); // set POST method
     669            curl_setopt($ch, CURLOPT_POSTFIELDS,
     670                "&app_key=28550b20478693975888f8cc5d1b72c97210a56e".
     671                "&meemi_id=".$meemi_screen_name.
     672                "&pwd=".hash("SHA256",$meemi_pwd).
     673                "&meme_type=text".
     674                "&fonte=via: ".$thispostlink.
     675                "&channels=".$chan.", ".$meemi_blog_chan.
     676                "&location=".$meemi_location.
     677                "&text_content=[i]".__('Ho aggiornato il post:','meemi_in_wordpress_3')." [/i] \n\n  [b]".$posted->post_title."[/b] - ".__('Leggilo qui:','meemi_in_wordpress_3')." ".$thispostlink.
     678                "&"); // add POST fields
     679            $result = curl_exec($ch); // run the whole process
     680
    622681            curl_close($ch);
    623682           
    624                        
    625         }elseif ( $_POST['aggiorna_meemi_post'] == "false" ) {
    626             //none
     683       
    627684           
    628685        ## scheduled post
     
    638695               
    639696                if($meemi_content == "part") {
     697                    $content_to_send = clean_caption($content_to_send);
    640698                    $content_to_send = substr(strip_tags($posted->post_content),0,400);
    641699                }else {
     
    657715                        "&channels=".$chan.", ".$meemi_blog_chan.
    658716                        "&location=".$meemi_location.
    659                         "&text_content=[b]".$posted->post_title.'[/b] - '.$content_to_send.
     717                        "&text_content=[b]".$posted->post_title."[/b]\n\n ".$content_to_send."\n\n[i]By: ".$author_nickname."[/i]".
    660718                        "&"); // add POST fields
    661719                    $result = curl_exec($ch); // run the whole process
     
    741799?>
    742800    </select>
     801    <br>
     802<label for="reinvia_meemi_post">Re-Invia post a Meemi?</label>
     803    <select name="reinvia_meemi_post" id="aggiorna_meemi_post">
     804        <option value="true">Si</option>
     805        <option value="false" selected="true">No</option>
     806?>
     807    </select>   
    743808<?php
    744809}
     
    767832    add_action('admin_menu', 'my_post_options_box');
    768833   
     834    # SHORTCODE FOR MEEMI CONTENT
     835    add_shortcode('meemi_content', 'meemi_content_func');
     836   
    769837?>
  • meemi-in-wordpress/trunk/readme.txt

    r181314 r208464  
    33Tags: meme, meemi, meemi.com, post, widget, coment, comments
    44Requires at least: 2.7.1
    5 Tested up to: 2.8.6
    6 Stable tag: 3.0.2
     5Tested up to: 2.9.1
     6Stable tag: 3.1
    77
    88Simple plugin to display your meme into your blog, send your post on Meemi, display Meemi's comments of your post in your blog and send comments to Meemi.
     
    3939== Changelog ==
    4040
     41= 3.1 =
     42* Added function to resend post to Meemi
     43* Added Meemi Content (Post content from Meemi with a simple shortocode like [meemi_content url="URL OF MEME"]
     44
    4145= 3.0.2 =
    4246* little bugfix
Note: See TracChangeset for help on using the changeset viewer.