# HG changeset patch # User Alessio Caiazza # Date 1242816101 0 # Node ID d0811661659fe8f80afa2e0ac4bcf319aa9405ef # Parent 0000000000000000000000000000000000000000 import from mercurial repo diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef aboutme.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aboutme.php Wed May 20 10:41:41 2009 +0000 @@ -0,0 +1,501 @@ +Social Links +Author: Alessio Caiazza +Version: 1.0.0 +Author URI: http://alessiocaiazza.info + +/* Social Links Copyright 2008 Kareem Sultan (email : kareemsultan@gmail.com) */ +/* + (c) 2009 Alessio Caiazza +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 2 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, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +http://www.gnu.org/licenses/gpl.txt + +*/ + +//call install function upon activation + register_activation_hook(__FILE__,'social_links_install'); + +//TO DO use these definitions instead +define('SOCIAL_LINKS_VERSION', '1.0.0'); +define('SOCIAL_LINKS_DB_VERSION', '1.1'); + +define('KEY_SITE_ID',0); +define('KEY_IMAGE',1); +define('KEY_URL_TEMPLATE',2); +define('KEY_INSTRUCTION',3); +define('KEY_DISPLAY_NAME',4); + + //$sl_db_version = "1.0"; + $plugindir = get_settings('home').'/wp-content/plugins/'.dirname(plugin_basename(__FILE__)); + $pluginrelativedir = '/wp-content/plugins/'.dirname(plugin_basename(__FILE__)); + + $definitions = array( + array(0,'facebook.png','%userid%','Enter your complete Facebook profile URL','Facebook'), + array(1,'myspace.png','%userid%','Enter your complete MySpace URL.','MySpace'), + array(2,'linkedin.png','%userid%','Enter your complete LinkedIn URL.','LinkedIn'), + array(3,'picasa.png','http://picasaweb.google.com/%userid%','Enter your Picasa(Google) username.','Picasa Web Album'), + array(4,'flickr.png','http://flickr.com/photos/%userid%','Enter your flickr username','Flickr'), + array(5,'youtube.png','http://www.youtube.com/%userid%','Enter your YouTube username','YouTube'), + array(6,'twitter.png','http://twitter.com/%userid%','Enter your Twitter username','Twitter'), + array(7,'pownce.png','http://pownce.com/%userid%','Enter your Pownce username','Pownce'), + array(8,'plurk.png','http://www.plurk.com/user/%userid%','Enter your Plurk username','Plurk'), + array(9,'digg.png','http://www.digg.com/users/%userid%','Enter your Digg username.','Digg'), + array(10,'delicious.png','http://delicious.com/%userid%','Enter your Delicious username','Delicious'), + array(11,'blogmarks.png','http://blogmarks.net/user/%userid%','Enter your BlogMarks username.','BlogMarks'), + array(12,'stumbleupon.png','http://%userid%.stumbleupon.com','Enter your Stumble Upon username','Stumble Upon'), + array(13,'lastfm.png','http://www.last.fm/user/%userid%','Enter your Last.fm username','Last.fm'), + array(14,'amazon.png','%userid%','Enter your complete Amazon Wishlist URL','Amazon Wishlist'), + array(15,'blog.png','%userid%','Enter the complete blog URL.','Blog'), + array(16,'jeqq.png','http://www.jeqq.com/user/view/profile/%userid%','Enter your Jeqq username','Jeqq'), + array(17,'dapx.png','%userid%','Enter your complete Dapx URL.','Dapx'), + array(18,'xing.jpg','%userid%','Enter your complete Xing URL.','Xing'), + array(19,'sixent.png','http://%userid%.sixent.com/','Enter your Sixent username','Sixent'), + array(20,'technorati.jpg','http://technorati.com/people/technorati/%userid%/','Enter your Technorati username.','Technorati'), + array(21,'friendfeed.png','http://friendfeed.com/%userid%','Enter your FriendFeed username.','FriendFeed'), + array(22,'identica.png','http://identi.ca/%userid%','Enter your Identi.ca username.','Identi.ca'), + array(23,'bitbucket.png','http://bitbucket.org/%userid%','Enter your Bitbucket username.','Bitbucket'), + array(24,'github.png','http://github.com/%userid%','Enter your Github username.','Github') + ); + + + + +function social_links_wrapper(){ + +// This only works if the widget api is installed +if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') ) + return; // ...and if not, exit gracefully from the script. + +//WPD_print('Filename: '.__FILE__); +//WPD_print('DB version: '.get_option( "SOCIAL_LINKS_DB_VERSION" )); + // Displays the icons in the sidebar + function widget_social_links($args) { + global $definitions; + extract($args); + + $options = get_option('widget_social_links'); + $title = empty($options['title']) ? 'About Me' : $options['title']; + $width = empty($options['width']) ? 20 : $options['width']; + + echo $before_widget; + echo $before_title . $title . $after_title ; + + echo ''; + echo "'; + echo $after_widget; + + } + + //Config Panel + function widget_social_links_control() { + global $definitions; + $options = get_option('widget_social_links'); + + if ( $_POST['social-links-submit'] ) { + // Clean up control form submission options + $newoptions['title'] = strip_tags(stripslashes($_POST['social-links-title'])); + $newoptions['width'] = strip_tags(stripslashes($_POST['social-links-width'])); + + + if ( $options != $newoptions ) { + $options = $newoptions; + update_option('widget_social_links', $options); + } + } + + $title = empty($options['title']) ? 'About Me' : $options['title']; + $width = empty($options['width']) ? 100 : $options['width']; + + ?> + + + + +
+ +
+ +
+ + + prefix . "social_links"; + $sql = 'delete from ' . $table_name . ' where id='.$linkId; + $result = $wpdb->query($wpdb->prepare($sql)); + + if($result == 1) + $result = 'Removed link.'; + else + $result = 'There was a problem deleting the link. Refresh the page and try again.'.$sql; + //WPD_print($result); + die(' + $("message").innerHTML = "'.$result.'"; + $("message").className="updated fade"; + $("message").style.visibility = "visible"; + '); + } + + + + + + function insertNetwork($id,$value){ + + + //WPD_print('Inserting new network'); + global $wpdb; + + //WPD_print('networkID='.$id.' data='.$value); + $table_name = $wpdb->prefix . "social_links"; + $sql = 'Insert into ' . $table_name . ' (network_id,user_info,sort_order) VALUES ("'.$id.'","'.$value.'",1000)'; + $result = $wpdb->query($wpdb->prepare($sql)); + //WPD_print($sql); + return $result; + } + + function getSocialLinks(){ + global $wpdb; + $table_name = $wpdb->prefix . "social_links"; + $sql = 'Select * from ' . $table_name . ' order by sort_order'; + $results = $wpdb->get_results($sql,ARRAY_N); + ////WPD_print("Select networks results: ".$results); + return $results; + + } + + function generateSocialLinksInnerHTML(){ + global $definitions; + global $plugindir; + + $options = get_option('widget_social_links'); + + $rows = getSocialLinks(); + if(count($rows)==0) + return; + ////WPD_print("Found".count($rows)." networks."); + + foreach ($rows as $row) { + //WPD_print("SiteID: " . $row[1]); + $linkInfoArray = $definitions[$row[1]]; + //WPD_print('network info '. $linkInfoArray); + $url = str_replace("%userid%",$row[2],$linkInfoArray[KEY_URL_TEMPLATE]); + $innerHTML = $innerHTML . "".$linkInfoArray[KEY_DISPLAY_NAME].""; + if($row != $rows[count($rows)-1]){ + $innerHTML = $innerHTML."\n"; + } + } + + return $innerHTML; + } + + function generateSocialLinksPreviewInnerHTML($delimiter){ + global $definitions; + global $plugindir; + + $rows = getSocialLinks(); + if(count($rows)==0) + return; + //WPD_print("Found ".count($rows)." networks."); + + foreach ($rows as $row) { + //WPD_print("SiteID: " . $row[2]); + //var_dump($row); + $linkInfoArray = $definitions[$row[1]]; + //var_dump($linkInfoArray); + //WPD_print('network info '. $linkInfoArray); + $url = str_replace("%userid%",$row[2],$linkInfoArray[KEY_URL_TEMPLATE]); + $innerHTML = $innerHTML . "".$linkInfoArray[KEY_DISPLAY_NAME].""; + if($row != $rows[count($rows)-1]){ + $innerHTML = $innerHTML.$delimiter; + } + } + + return $innerHTML; + } + + /* + function generateSocialLinksData(){ + global $definitions; + + $rows = getSocialLinks(); + if(count($rows)==0) + return; + ////WPD_print("Found".count($rows)." networks."); + $data = ''; + foreach ($rows as $row) { + $linkInfoArray = $definitions[$row[2]]; + $data += "link_$row[0],$linkInfoArray[0],$linkInfoArray[1],$linkInfoArray[4]\n"; + } + return $data; + + } + */ + + function social_links_admin_menu(){ + global $pluginrelativedir; + //add_options_page('Social Links Settings', 'Social Links', 8,$pluginrelativedir.'/edit-sociallinks.php'); + add_management_page('Social Links Settings (About Me)', 'Social Links', 8,__FILE__,'widget_social_links_settings'); + + global $plugindir; + wp_enqueue_script('social-links', $plugindir . '/javascript.js',array('sack')); + wp_enqueue_script('scriptaculous'); + } + + function addHeaderCode(){ + //WPD_print("header code"); + global $plugindir; + echo '' . "\n"; + + } + + + + ////WPD_print("Registering plugin"); + + add_action('wp_head','addHeaderCode'); + + + + //Add action to load sub menu + add_action('admin_menu', 'social_links_admin_menu'); + + + + + //Add ajax callback action called from client side javascript + add_action('wp_ajax_social_links_add_network', 'wp_ajax_social_links_add_network' ); + add_action('wp_ajax_social_links_delete_network', 'wp_ajax_social_links_delete_network' ); + + register_sidebar_widget('Social Links', 'widget_social_links'); + register_widget_control('Social Links', 'widget_social_links_control'); + + }//End of SocialLinks class + + +add_action('plugins_loaded','social_links_wrapper'); + +//todo handle auto db table update +function social_links_install(){ + //require_once('datastore.php'); + //sl_install(); + + global $wpdb; + + //WPD_print("Installing Social Links Plugin"); + //echo '
Activation social links
'; + + $table_name = $wpdb->prefix . "social_links"; + + // $installed_ver = get_option( "SOCIAL_LINKS_DB_VERSION" ); + + if($wpdb->get_var("show tables like '$table_name'") != $table_name ) { + + $sql = "CREATE TABLE " . $table_name . " ( + id mediumint(9) NOT NULL AUTO_INCREMENT, + network_id int not null, + user_info VARCHAR(55) NOT NULL, + sort_order int not null DEFAULT 0, + UNIQUE KEY id (id) + );"; + + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); + dbDelta($sql); + + + add_option("SOCIAL_LINKS_DB_VERSION", SOCIAL_LINKS_DB_VERSION); + } + } + + +//Administration page +$message; +$messageClass; +function widget_social_links_settings(){ + + if (isset($_POST['saveorder'])) + { + saveSortOrder(); + } + + + global $definitions; + global $message; + global $messageClass; + global $plugindir; + + $visibility = 'hidden'; + if(!empty($messageClass)) + $visibility = 'visible'; + + ?> + + +
+

About Me

+ + +
+
+

Add New Social Link

+ + + +
+ + +
+
+ +
+ +
+

Preview

+
+ +
+ + + + +
+
+ +
+
+
+
+

+ To add a new link select the network from the drop down, fill in the appropriate information and press enter.
+ To change the order they appear, rearrange the icons in the preview and click 'Save Order'.
+ To delete a link, simply drag it to the trash can. +

+
+
+ + prefix . "social_links"; + foreach($newSortorderArray["displayDiv"] as $order => $id){ + //WPD_print('Order: '.$order.' Value: '.$id); + + $sql = 'Update ' . $table_name . ' Set sort_order='.$order.' where id='.$id; + $result = $wpdb->query($wpdb->prepare($sql)); + //WPD_print('Result for '.$sql.' is '.$result); + + } + $message = 'Saved links\' order.'; + } + else{ + $message = 'No items to save.'; + } + $messageClass = 'updated fade'; + } +} + + +?> \ No newline at end of file diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/Google.png Binary file images/Google.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/ajax-loader.gif Binary file images/ajax-loader.gif has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/amazon.png Binary file images/amazon.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/bitbucket.png Binary file images/bitbucket.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/blog.png Binary file images/blog.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/blogmarks.png Binary file images/blogmarks.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/dapx.png Binary file images/dapx.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/delicious.png Binary file images/delicious.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/digg.png Binary file images/digg.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/facebook.png Binary file images/facebook.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/flickr.png Binary file images/flickr.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/friendfeed.png Binary file images/friendfeed.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/github.png Binary file images/github.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/googlereader.png Binary file images/googlereader.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/identica.png Binary file images/identica.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/jeqq.png Binary file images/jeqq.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/lastfm.png Binary file images/lastfm.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/linkedin.png Binary file images/linkedin.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/myspace.png Binary file images/myspace.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/picasa.png Binary file images/picasa.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/plurk.png Binary file images/plurk.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/pownce.png Binary file images/pownce.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/sixent.png Binary file images/sixent.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/stumbleupon.png Binary file images/stumbleupon.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/technorati.jpg Binary file images/technorati.jpg has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/trash.jpg Binary file images/trash.jpg has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/trashfull.jpg Binary file images/trashfull.jpg has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/twitter.png Binary file images/twitter.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/xing.jpg Binary file images/xing.jpg has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef images/youtube.png Binary file images/youtube.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef javascript.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javascript.js Wed May 20 10:41:41 2009 +0000 @@ -0,0 +1,114 @@ + +function social_links_ajax_saveOrder(){ + $('sortOrderData').value = Sortable.serialize("displayDiv"); +} + +function selectionChanged(){ + + + var label = $("instruction"); + var dropdown = $("networkDropdown"); + var settingInput = $("addSettingInput"); + var addButton = $("addButton"); + + if(dropdown.selectedIndex != 0){ + var currentSelection = dropdown.options[dropdown.selectedIndex] + label.innerHTML = currentSelection.getAttribute('instruction'); + settingInput.value = ''; + addButton.disabled = false; + } + else{ + label.innerHTML = ''; + settingInput.value = ''; + addButton.disabled = true; + } + +} + +function onTextKeyDown(){ + if(event.keyCode == 13){ + social_links_ajax_addNetwork( + document.getElementById('networkDropdown').selectedIndex - 1, + document.getElementById('addSettingInput'), + document.getElementById('responseDiv') + ); + } +} + +function onDropToTrash(){ + var span = $('trash').firstChild.nextSibling; + if(span){ + social_links_ajax_delete_network(span.id.split('_')[1]); + span.parentNode.removeChild(span); + } + +} + +function addLoadingIcon(){ + var img = Builder.node('span',{ + id:'loadingImage', + className:'linkWrapper', + title:'Loading', + style:'position:relative;'}, + Builder.node('img',{src:'/wp-content/plugins/about-me/images/ajax-loader.gif',style:'margin:2px'},'')); + //console.log(img); + $('displayDiv').appendChild(img); +} + +function social_links_ajax_addNetwork(selectedIndex,textInput,responseDiv){ + addLoadingIcon(); + var siteID = $('networkDropdown').options[selectedIndex].value; + var mysack = new sack(getWordpressBaseLocation()+"wp-admin/admin-ajax.php" ); + + //console.log('Adding network '+siteID+ ': '+textInput); + + mysack.execute = 1; + mysack.method = 'POST'; + mysack.setVar( "action", "social_links_add_network" ); + mysack.setVar( "siteID", siteID ); + mysack.setVar( "value", textInput.value ); + mysack.encVar( "cookie", document.cookie, false ); + mysack.onError = function() { alert('Ajax error while adding new network' )}; + mysack.runAJAX(); + + + return true; + +} + +function social_links_ajax_delete_network(linkId){ + + var mysack = new sack(getWordpressBaseLocation()+"wp-admin/admin-ajax.php" ); + + mysack.execute = 1; + mysack.method = 'POST'; + mysack.setVar( "action", "social_links_delete_network" ); + mysack.setVar( "linkId", linkId ); + mysack.encVar( "cookie", document.cookie, false ); + mysack.onError = function() { alert('Ajax error while adding new network' )}; + + mysack.runAJAX(); + + createSortables(); + + return true; +} + +function createSortables(){ + Sortable.destroy('displayDiv'); + Sortable.destroy('trash'); + + targets = $$('.drop_target'); + Sortable.create('trash',{tag:'span',containment:targets,constraint:false,dropOnEmpty:true, + onUpdate: function(){ + onDropToTrash(); + } + }); + Sortable.create('displayDiv',{tag:'span',containment:targets,overlap:'horizontal',constraint:false}); + +} + +function getWordpressBaseLocation(){ + return $('callBackUrl').value.split('wp-content/')[0]; +} + \ No newline at end of file diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef readme.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/readme.txt Wed May 20 10:41:41 2009 +0000 @@ -0,0 +1,98 @@ +=== About me === + +Contributors: nolith, kareemsultan + + +Tags: widget,sidebar,Social network, profile page,social link,icon links + +Requires at least: 2.6 + +Tested up to: 2.7.1 + +Stable tag: 1.0.0 + + + +About me is a sidebar widget that displays icon links to your profile pages on other social networking sites. Based on Social Links. + + + +== Description == + + + +About me is a sidebar widget that displays icon links to your profile pages on other social networking sites. +This plugin is forked from [SocialLinks](http://blog.maybe5.com/?page_id=94 "Social Links page") + + +**Supported Networks:** + + +* Amazon Wishlist +* Bitbucket +* Blogs +* BlogMarks +* Dapx +* Delicious +* Digg +* Facebook +* Flickr +* FriendFeed +* Github +* Identi.ca +* Jeqq +* Last FM +* Linked In +* My Space +* Picasa Web Albums +* Plurk +* Pownce +* Sixent +* Stumble Upon +* Technorati +* Twitter +* YouTube +* Xing + + + +== Installation == + + + +1. Download the installation zip file and unzip leaving the directory structure in tact. +1. Upload the newly unzipped 'about-me' folder to the `/wp-content/plugins/` folder +1. Activate the About Me plugin from the 'Plugins' menu. + +1. Add the widget to your sidebar from the 'Widgets' design page. + +1. Add your social links from the 'Social Links' page under the 'Management' page. + + + +== Frequently Asked Questions == + + + += How do I get another website supported? = + + + +Just post a comment to [my blog](http://abisso.org/index.php/projects/about-me/) or [open a ticket](http://bb.alessiocaiazza.info/about-me/issues/new/) with a link to any user page on that site. + +I will add suggested sites in upcoming releases. + + + + +== Screenshots == + + + +1. About Me sidebar widget + + + + +== Change Log == +* 1.0.0 NEW:Bitbucket, Identi.ca, GitHub support FIX:now works with Lightbox2/Slimbox plugins \ No newline at end of file diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef screenshot-1.png Binary file screenshot-1.png has changed diff -r 0000000000000000000000000000000000000000 -r d0811661659fe8f80afa2e0ac4bcf319aa9405ef stylesheet.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stylesheet.css Wed May 20 10:41:41 2009 +0000 @@ -0,0 +1,6 @@ +#socialLinksContainer a img{ + margin-top:2px; + margin-right:2px; + border-style:none; + background-color:none; +} \ No newline at end of file