williamn / sweetcron

Automatically exported from code.google.com/p/sweetcron
Other
0 stars 0 forks source link

PATCH: Non-hardcoded username filter for Twitter plugin #49

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
--- a/system/application/plugins/twitter_com.php
+++ b/system/application/plugins/twitter_com.php

class Twitter_com {
    function pre_db($item)
    {
        //all we want to do before twitter stuff gets added to the db is to remove the username 
from the front of the title / content
-       $username = 'yongfook';
-       $item->item_title = str_replace($username.':', '', $item->item_title);
+       // Using Regex instead of hardcoding username
+       $item->item_title = preg_replace('/^\w+:\s/', '', $item->item_title);
        //remove item_content as it's just the same as the title anyway
        $item->item_content = '';
        return $item;
}

Original issue reported on code.google.com by jm%grokc...@gtempaccount.com on 30 Aug 2008 at 11:40

GoogleCodeExporter commented 9 years ago
added the ability to turn @'s into links back to the user. 

class Twitter_com {

    function pre_db($item)
    {
        //all we want to do before twitter stuff gets added to the db is to remove the
username from the front of the title / content
        $username = 'yongfook';
        $item->item_title = str_replace($username.':', '', $item->item_title);
        // Using Regex instead of hardcoding username
        $item->item_title = preg_replace('/^\w+:\s/', '', $item->item_title);
        // Look for @'s make them links to the user profile
        $item->item_title = eregi_replace('((@)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','@<a
href="http://twitter.com/\\1" target="_blank">\\1</a>', $item->item_title);
        $item->item_title = eregi_replace("/@", "/", $item->item_title);
        $item->item_title = eregi_replace(">@", ">", $item->item_title);
        //remove item_content as it's just the same as the title anyway
        $item->item_content = '';
        return $item;
}
    function pre_display($item)
    {
        return $item;
    }
} 

Original comment by cronc...@gmail.com on 31 Aug 2008 at 3:43