00001 <?php
00002 
00003 
00004 
00005 
00006 
00007 
00008 class SocialBookmarking {
00009         const BLOGSMARK = 'blogsmark';
00010         const DELICIOUS = 'del.icio.us';
00011         const DIGG = 'digg';
00012         const FACEBOOK = 'facebook';
00013         const FURL = 'furl';
00014         const GOOGLE = 'google';
00015         const GOOGLE_BUZZ = 'buzz';
00016         const YAHOO = 'yahoo';
00017         
00018         const MYSPACE = 'myspace';
00019         const NETSCAPE = 'netscape';
00020         const NEWSVINE = 'newsvine';
00021         const REDDIT = 'reddit';
00022         const STUMBLEUPON = 'stumbleupon';
00023         const TECHNORATI = 'technarati';
00024         const TWITTER = 'twitter';
00025         const WINDOWS_LIVE = 'live';
00026         const EMAIL = 'email';
00027         
00028         const MISTER_WONG = 'misterwong';
00029         const YIGG = 'yigg';
00030         const WEBNEWS = 'webnews';
00031         
00032 
00033 
00034 
00035 
00036 
00037         const SET_POPULAR_EN = 'set_en';
00038 
00039 
00040 
00041         const SET_POPULAR_DE = 'set_de';
00042 
00043 
00044 
00045         const SET_TECH_EN = 'set_tech_en';
00046         
00047 
00048 
00049 
00050 
00051 
00052         private static $defined_sets = array();
00053         
00054 
00055 
00056 
00057 
00058 
00059         public static function get_all_services() {
00060                 $ret = RuntimeCache::get('socialbookmarking_services', false);
00061                 if ($ret === false) {
00062                         Load::components('socialbookmark');
00063                         $ret = array(
00064                                 self::EMAIL => new SocialBookmark(tr('Mail to a friend', 'socialbookmarking'), 'mailto:?subject=%TITLE%&body=%TITLE%: %URL%', 'email.gif'),
00065                                 self::TWITTER => new SocialBookmark(tr('Tweet it', 'socialbookmarking'), 'http://twitter.com/home?status=%TITLE%:+%URL%', 'twitter.gif'),
00066                                 self::FACEBOOK => new SocialBookmark(tr('Send to Facebook', 'socialbookmarking'), 'http://www.facebook.com/sharer.php?u=%URL%&t=%TITLE%', 'facebook.gif'),
00067                                 self::GOOGLE_BUZZ => new SocialBookmark(tr('Buzz this!', 'socialbookmarking'), 'http://www.google.com/reader/link?url=%URL%&title=%TITLE%', 'google_buzz.png'),
00068                                 self::DIGG => new SocialBookmark(tr('Digg it!', 'socialbookmarking'), 'http://digg.com/submit?phase=2&url=%URL%', 'digg.png'),
00069                                 self::MYSPACE => new SocialBookmark(tr('Add to MySpace', 'socialbookmarking'), 'http://www.myspace.com/Modules/PostTo/Pages/?c=%URL%&t=%TITLE%', 'myspace.gif'),
00070                                 self::STUMBLEUPON => new SocialBookmark(tr('Bookmark on StumbleUpon', 'socialbookmarking'), 'http://www.stumbleupon.com/submit?url=%URL%&title=%TITLE%', 'stumbleupon.gif'),
00071                                 self::REDDIT => new SocialBookmark(tr('Bookmark on Reddit', 'socialbookmarking'), 'http://reddit.com/submit?url=%URL%&title=%TITLE%', 'reddit.gif'),
00072                                 self::DELICIOUS => new SocialBookmark(tr('Add to Delicious', 'socialbookmarking'), 'http://delicious.com/post?url=%URL%&title=%TITLE%', 'delicious.png'),
00073                                 self::GOOGLE => new SocialBookmark(tr('Add to Google Bookmarks', 'socialbookmarking'), 'http://www.google.com/bookmarks/mark?op=add&bkmk=%URL%&title=%TITLE%', 'google.png'),
00074                                 self::WINDOWS_LIVE => new SocialBookmark(tr('Bookmark on Live.com', 'socialbookmarking'), 'https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url=%URL%&title=%TITLE%&top=1', 'live.gif'),
00075                                 self::TECHNORATI => new SocialBookmark(tr('Add to Technorati', 'socialbookmarking'), 'http://www.technorati.com/faves?add=%URL%', 'technorati.gif'),
00076                                 
00077                                 self::FURL => new SocialBookmark(tr('Add to Furl', 'socialbookmarking'), 'http://furl.net/storeIt.jsp?t=%TITLE%&u=%URL%', 'furl.png'),
00078                                 self::NETSCAPE => new SocialBookmark(tr('Boomark on Netscape', 'socialbookmarking'), 'http://www.netscape.com/submit/?U=%URL%&T=%TITLE%', 'netscape.png'),
00079                                 self::NEWSVINE => new SocialBookmark(tr('Bookmark on Newsvine', 'socialbookmarking'), 'http://www.newsvine.com/_wine/save?u=%URL%&h=%TITLE%', 'newsvine.gif'),
00080                                 self::BLOGSMARK => new SocialBookmark(tr('Add to BlogMarks.net', 'socialbookmarking'), 'http://blogmarks.net/my/new.php?mini=1&url=%URL%&title=%TITLE%', 'blogmarks.gif'),
00081                                 
00082                                 
00083                                 self::MISTER_WONG => new SocialBookmark(tr('Bookmark at Mister Wong', 'socialbookmarking'), 'http://www.mister-wong.com/index.php?action=addurl&bm_url=%URL%&bm_description=%TITLE%', 'misterwong.gif'),
00084                                 self::YIGG => new SocialBookmark(tr('Add to Yigg', 'socialbookmarks'), 'http://yigg.de/neu?exturl=%URL%&title=%TITLE%', 'yigg.png'),
00085                                 self::WEBNEWS => new SocialBookmark(tr('Post on Webnews', 'socialbookmarks'), 'http://www.webnews.de/einstellen?url=%URL%&title=%TITLE%', 'webnews.gif'),
00086                                 
00087                         );
00088                         RuntimeCache::set('socialbookmarking_services', $ret);
00089                 }
00090                 return $ret;
00091         }
00092         
00093 
00094 
00095 
00096 
00097 
00098 
00099         public static function create_set($set_name) {
00100                 $ret = Arr::get_item(self::$defined_sets, $set_name, false);
00101                 if ($ret === false) {
00102                         switch ($set_name) {
00103                                 case self::SET_POPULAR_EN:
00104                                         $ret = array(
00105                                                 self::EMAIL, 
00106                                                 self::FACEBOOK, self::MYSPACE, self::TWITTER, 
00107                                                 self::DIGG, self::STUMBLEUPON, self::REDDIT, self::DELICIOUS, 
00108                                                 self::GOOGLE, self::WINDOWS_LIVE, self::TECHNORATI 
00109                                         );
00110                                         break;
00111                                 case self::SET_TECH_EN:
00112                                         $ret = array(
00113                                                 self::EMAIL, 
00114                                                 self::TWITTER, self::FACEBOOK, self::GOOGLE_BUZZ,  
00115                                                 self::DIGG, self::DELICIOUS, self::STUMBLEUPON, self::REDDIT
00116                                         );
00117                                         break;
00118                                 case self::SET_POPULAR_DE:
00119                                         $ret = array(
00120                                                 self::EMAIL, 
00121                                                 self::FACEBOOK, self::MYSPACE, self::TWITTER, 
00122                                                 self::MISTER_WONG, self::YIGG, self::DELICIOUS,
00123                                                 self::WEBNEWS, 
00124                                                 self::GOOGLE, self::WINDOWS_LIVE 
00125                                         );
00126                                         break;                          
00127                                 default:
00128                                         $ret = array(self::EMAIL);
00129                                         break;
00130                         }       
00131                 }
00132                 return $ret;
00133         }
00134         
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144         public static function define_set($name, $arr_services) {
00145                 self::$defined_sets[$name] = $arr_services;
00146         }
00147         
00148 
00149 
00150 
00151 
00152 
00153 
00154         public static function get_service($name) {
00155                 $all = self::get_all_services();
00156                 return Arr::get_item($all, $name, false);
00157         } 
00158 }