Alessio Caiazza is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

nolith / About Me http://abisso.org/index.php/projects/about-me/

Put in a widget all your social network links with this amazing Worpress plugin ;) (based on social-link http://blog.maybe5.com/?page_id=94)

Clone this repository (size: 313.2 KB): HTTPS / SSH
hg clone https://bitbucket.org/nolith/about-me
hg clone ssh://hg@bitbucket.org/nolith/about-me

About Me / aboutme.php

commit
d0811661659f
branch
default
tags
1.0.0

import from mercurial repo

1
d0811661659f
<?php
2
d0811661659f
/*
3
d0811661659f
Plugin Name: About Me
4
d0811661659f
Plugin URI: http://abisso.org/index.php/projects/about-me/
5
d0811661659f
Description: About Me is a sidebar widget that displays icon links to your profile pages on other social networking sites. Forked from <a href="http://blog.maybe5.com/?page_id=94">Social Links</a>
6
d0811661659f
Author: Alessio Caiazza
7
d0811661659f
Version: 1.0.0
8
d0811661659f
Author URI: http://alessiocaiazza.info
9
d0811661659f
10
d0811661659f
/*  Social Links Copyright 2008  Kareem Sultan  (email : kareemsultan@gmail.com) */
11
d0811661659f
/*
12
d0811661659f
	(c) 2009 Alessio Caiazza
13
d0811661659f
This program is free software; you can redistribute it and/or modify
14
d0811661659f
it under the terms of the GNU General Public License as published by
15
d0811661659f
the Free Software Foundation; either version 2 of the License, or
16
d0811661659f
(at your option) any later version.
17
d0811661659f
18
d0811661659f
This program is distributed in the hope that it will be useful,
19
d0811661659f
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
d0811661659f
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
d0811661659f
GNU General Public License for more details.
22
d0811661659f
23
d0811661659f
You should have received a copy of the GNU General Public License
24
d0811661659f
along with this program; if not, write to the Free Software
25
d0811661659f
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26
d0811661659f
27
d0811661659f
http://www.gnu.org/licenses/gpl.txt
28
d0811661659f
29
d0811661659f
*/
30
d0811661659f
31
d0811661659f
//call install function upon activation
32
d0811661659f
		register_activation_hook(__FILE__,'social_links_install');
33
d0811661659f
		
34
d0811661659f
//TO DO use these definitions instead
35
d0811661659f
define('SOCIAL_LINKS_VERSION', '1.0.0');
36
d0811661659f
define('SOCIAL_LINKS_DB_VERSION', '1.1');
37
d0811661659f
38
d0811661659f
define('KEY_SITE_ID',0);
39
d0811661659f
define('KEY_IMAGE',1);
40
d0811661659f
define('KEY_URL_TEMPLATE',2);
41
d0811661659f
define('KEY_INSTRUCTION',3);
42
d0811661659f
define('KEY_DISPLAY_NAME',4);
43
d0811661659f
  
44
d0811661659f
 //$sl_db_version = "1.0";
45
d0811661659f
 $plugindir = get_settings('home').'/wp-content/plugins/'.dirname(plugin_basename(__FILE__));
46
d0811661659f
 $pluginrelativedir = '/wp-content/plugins/'.dirname(plugin_basename(__FILE__));
47
d0811661659f
48
d0811661659f
 $definitions = array(
49
d0811661659f
	 array(0,'facebook.png','%userid%','Enter your complete Facebook profile URL','Facebook'),
50
d0811661659f
	 array(1,'myspace.png','%userid%','Enter your complete MySpace URL.','MySpace'),
51
d0811661659f
	 array(2,'linkedin.png','%userid%','Enter your complete LinkedIn URL.','LinkedIn'),
52
d0811661659f
   array(3,'picasa.png','http://picasaweb.google.com/%userid%','Enter your Picasa(Google) username.','Picasa Web Album'),
53
d0811661659f
	 array(4,'flickr.png','http://flickr.com/photos/%userid%','Enter your flickr username','Flickr'),
54
d0811661659f
	 array(5,'youtube.png','http://www.youtube.com/%userid%','Enter your YouTube username','YouTube'),
55
d0811661659f
	 array(6,'twitter.png','http://twitter.com/%userid%','Enter your Twitter username','Twitter'),
56
d0811661659f
	 array(7,'pownce.png','http://pownce.com/%userid%','Enter your Pownce username','Pownce'),
57
d0811661659f
	 array(8,'plurk.png','http://www.plurk.com/user/%userid%','Enter your Plurk username','Plurk'),
58
d0811661659f
	 array(9,'digg.png','http://www.digg.com/users/%userid%','Enter your Digg username.','Digg'),
59
d0811661659f
	 array(10,'delicious.png','http://delicious.com/%userid%','Enter your Delicious username','Delicious'),
60
d0811661659f
	 array(11,'blogmarks.png','http://blogmarks.net/user/%userid%','Enter your BlogMarks username.','BlogMarks'),
61
d0811661659f
	 array(12,'stumbleupon.png','http://%userid%.stumbleupon.com','Enter your Stumble Upon username','Stumble Upon'),
62
d0811661659f
   array(13,'lastfm.png','http://www.last.fm/user/%userid%','Enter your Last.fm username','Last.fm'),
63
d0811661659f
	 array(14,'amazon.png','%userid%','Enter your complete Amazon Wishlist URL','Amazon Wishlist'),
64
d0811661659f
	 array(15,'blog.png','%userid%','Enter the complete blog URL.','Blog'),
65
d0811661659f
	 array(16,'jeqq.png','http://www.jeqq.com/user/view/profile/%userid%','Enter your Jeqq username','Jeqq'),
66
d0811661659f
   array(17,'dapx.png','%userid%','Enter your complete Dapx URL.','Dapx'),
67
d0811661659f
	 array(18,'xing.jpg','%userid%','Enter your complete Xing URL.','Xing'),
68
d0811661659f
	 array(19,'sixent.png','http://%userid%.sixent.com/','Enter your Sixent username','Sixent'),
69
d0811661659f
	 array(20,'technorati.jpg','http://technorati.com/people/technorati/%userid%/','Enter your Technorati username.','Technorati'),
70
d0811661659f
	 array(21,'friendfeed.png','http://friendfeed.com/%userid%','Enter your FriendFeed username.','FriendFeed'),
71
d0811661659f
	 array(22,'identica.png','http://identi.ca/%userid%','Enter your Identi.ca username.','Identi.ca'),
72
d0811661659f
	 array(23,'bitbucket.png','http://bitbucket.org/%userid%','Enter your Bitbucket username.','Bitbucket'),
73
d0811661659f
	 array(24,'github.png','http://github.com/%userid%','Enter your Github username.','Github')
74
d0811661659f
   );
75
d0811661659f
76
d0811661659f
77
d0811661659f
78
d0811661659f
79
d0811661659f
function social_links_wrapper(){
80
d0811661659f
81
d0811661659f
// This only works if the widget api is installed
82
d0811661659f
if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
83
d0811661659f
	return; // ...and if not, exit gracefully from the script.
84
d0811661659f
85
d0811661659f
//WPD_print('Filename: '.__FILE__);
86
d0811661659f
//WPD_print('DB version: '.get_option( "SOCIAL_LINKS_DB_VERSION" ));
87
d0811661659f
		// Displays the icons in the sidebar
88
d0811661659f
		function widget_social_links($args) {
89
d0811661659f
			global $definitions;
90
d0811661659f
			extract($args);
91
d0811661659f
					
92
d0811661659f
			$options = get_option('widget_social_links');
93
d0811661659f
				$title = empty($options['title']) ? 'About Me' : $options['title'];
94
d0811661659f
			$width =  empty($options['width']) ? 20 : $options['width'];
95
d0811661659f
		
96
d0811661659f
				echo $before_widget;
97
d0811661659f
				echo $before_title . $title . $after_title ;
98
d0811661659f
		
99
d0811661659f
			echo '<!-- About Me Version: '. SOCIAL_LINKS_VERSION .' -->';
100
d0811661659f
			echo "<div id='socialLinksContainer' style='width:$width"."px;'>";
101
d0811661659f
			echo generateSocialLinksInnerHTML();
102
d0811661659f
			echo '</div>';
103
d0811661659f
			echo $after_widget;
104
d0811661659f
			
105
d0811661659f
		}
106
d0811661659f
	
107
d0811661659f
		  //Config Panel
108
d0811661659f
		function widget_social_links_control() {
109
d0811661659f
			global $definitions;
110
d0811661659f
			$options = get_option('widget_social_links');
111
d0811661659f
	
112
d0811661659f
			if ( $_POST['social-links-submit'] ) {
113
d0811661659f
				// Clean up control form submission options
114
d0811661659f
				$newoptions['title'] = strip_tags(stripslashes($_POST['social-links-title']));
115
d0811661659f
				$newoptions['width'] = strip_tags(stripslashes($_POST['social-links-width']));
116
d0811661659f
	
117
d0811661659f
	
118
d0811661659f
				if ( $options != $newoptions ) {
119
d0811661659f
					$options = $newoptions;
120
d0811661659f
					update_option('widget_social_links', $options);
121
d0811661659f
				}
122
d0811661659f
			}
123
d0811661659f
	
124
d0811661659f
			$title = empty($options['title']) ? 'About Me' : $options['title'];
125
d0811661659f
			$width = empty($options['width']) ? 100 : $options['width'];
126
d0811661659f
	
127
d0811661659f
			?>
128
d0811661659f
			
129
d0811661659f
				<table>
130
d0811661659f
					<tr><td>
131
d0811661659f
						<label for="social-links-title">Widget title: <input type="text" id="social-links-title" name="social-links-title" value="<?php echo $title; ?>" /></label>
132
d0811661659f
					</td></tr>
133
d0811661659f
					<tr><td>
134
d0811661659f
						<label for="social-links-width">Width: <input type="text" id="social-links-width" name="social-links-width" style="width:25px;" value="<?php echo $width; ?>" /> pixels</label>
135
d0811661659f
					</td></tr>
136
d0811661659f
				</table>
137
d0811661659f
				<input type="hidden" name="social-links-submit" id="social-links-submit" value="1" />
138
d0811661659f
				
139
d0811661659f
			<?php
140
d0811661659f
		}//End of widget_social_links_control
141
d0811661659f
		
142
d0811661659f
		
143
d0811661659f
		function wp_ajax_social_links_add_network(){
144
d0811661659f
			// read submitted information
145
d0811661659f
			global $definitions;
146
d0811661659f
			
147
d0811661659f
			$siteID = $_POST['siteID'];
148
d0811661659f
			$data = $_POST['value'];
149
d0811661659f
			$messageId = $_POST['responseDiv'];
150
d0811661659f
			
151
d0811661659f
			$result = insertNetwork($siteID,$data);
152
d0811661659f
			if($result == 1)
153
d0811661659f
		 		$result = 'Link added.';
154
d0811661659f
		 	else
155
d0811661659f
		 		$result = 'There was a problem adding the link. Refresh the page and try again.';
156
d0811661659f
		 		
157
d0811661659f
		 	$innerHTML = generateSocialLinksPreviewInnerHTML('');
158
d0811661659f
			die('
159
d0811661659f
				$("message").innerHTML = "'.$result.'";
160
d0811661659f
				$("message").className="updated fade";
161
d0811661659f
				$("message").style.visibility = "visible";
162
d0811661659f
				document.getElementById("displayDiv").innerHTML = "'.$innerHTML.'";
163
d0811661659f
				createSortables();
164
d0811661659f
				
165
d0811661659f
				
166
d0811661659f
			');
167
d0811661659f
			
168
d0811661659f
			//Add this line to the above javascript to show the complete table.
169
d0811661659f
			//document.getElementById("editDiv").innerHTML = "' . generateSocialLinksEditInnerHTML(). '";
170
d0811661659f
		}
171
d0811661659f
		
172
d0811661659f
		//TODO: Implement the add ajax process to send data and let the javascript add child elements
173
d0811661659f
		//This is to avoid using innerHTML replacement and will then allow for more advanced client side effects
174
d0811661659f
	/*	function wp_ajax_social_links_add_network_send_data(){
175
d0811661659f
			// read submitted information
176
d0811661659f
			global $definitions;
177
d0811661659f
			
178
d0811661659f
			$selectedIndex = $_POST['networkIndex'];
179
d0811661659f
			$data = $_POST['value'];
180
d0811661659f
			
181
d0811661659f
			$result = insertNetwork($selectedIndex,$data);
182
d0811661659f
			$data = generateSocialLinksData();
183
d0811661659f
			//$result = 'fake insert';
184
d0811661659f
			die("$result
185
d0811661659f
				$('message').innerHTML = 'Database result is $result.';
186
d0811661659f
				$('message').class='updated fade';
187
d0811661659f
				$('message').style.visibility = 'visible';
188
d0811661659f
				updateSocialLinks($data);
189
d0811661659f
			");
190
d0811661659f
			
191
d0811661659f
		}
192
d0811661659f
		*/
193
d0811661659f
		function wp_ajax_social_links_delete_network(){
194
d0811661659f
			global $wpdb;
195
d0811661659f
		 	global $definitions;
196
d0811661659f
		 	
197
d0811661659f
			$linkId = $_POST['linkId'];
198
d0811661659f
		 	//WPD_print('deleting linkID='. $linkId);
199
d0811661659f
		 	$table_name = $wpdb->prefix . "social_links";
200
d0811661659f
		 	$sql = 'delete from ' .  $table_name . ' where id='.$linkId;
201
d0811661659f
		 	$result = $wpdb->query($wpdb->prepare($sql));
202
d0811661659f
		 	
203
d0811661659f
		 	if($result == 1)
204
d0811661659f
		 		$result = 'Removed link.';
205
d0811661659f
		 	else
206
d0811661659f
		 		$result = 'There was a problem deleting the link. Refresh the page and try again.'.$sql;
207
d0811661659f
		 	//WPD_print($result);
208
d0811661659f
		 	die('
209
d0811661659f
				$("message").innerHTML = "'.$result.'";
210
d0811661659f
				$("message").className="updated fade";
211
d0811661659f
				$("message").style.visibility = "visible";
212
d0811661659f
			');
213
d0811661659f
		}
214
d0811661659f
		
215
d0811661659f
		
216
d0811661659f
	
217
d0811661659f
	
218
d0811661659f
		 
219
d0811661659f
		 function insertNetwork($id,$value){
220
d0811661659f
		 
221
d0811661659f
		 	
222
d0811661659f
		 	//WPD_print('Inserting new network');
223
d0811661659f
		 	global $wpdb;
224
d0811661659f
		 	
225
d0811661659f
		 	//WPD_print('networkID='.$id.' data='.$value);
226
d0811661659f
		 	$table_name = $wpdb->prefix . "social_links";
227
d0811661659f
		 	$sql = 'Insert into ' .  $table_name . ' (network_id,user_info,sort_order) VALUES ("'.$id.'","'.$value.'",1000)';
228
d0811661659f
		 	$result = $wpdb->query($wpdb->prepare($sql));
229
d0811661659f
		 	//WPD_print($sql);
230
d0811661659f
		 	return $result;
231
d0811661659f
		 }
232
d0811661659f
		 
233
d0811661659f
		 function getSocialLinks(){
234
d0811661659f
		 	global $wpdb;
235
d0811661659f
		 	$table_name = $wpdb->prefix . "social_links";
236
d0811661659f
		 	$sql = 'Select * from ' .  $table_name . ' order by sort_order';
237
d0811661659f
		 	$results = $wpdb->get_results($sql,ARRAY_N);
238
d0811661659f
		 	////WPD_print("Select networks results: ".$results);
239
d0811661659f
		 	return $results;
240
d0811661659f
		 	
241
d0811661659f
		 }
242
d0811661659f
		 
243
d0811661659f
		 function generateSocialLinksInnerHTML(){
244
d0811661659f
		 	global $definitions;
245
d0811661659f
		 	global $plugindir;
246
d0811661659f
      
247
d0811661659f
		 	$options = get_option('widget_social_links');
248
d0811661659f
			
249
d0811661659f
		 	$rows = getSocialLinks();
250
d0811661659f
		 	if(count($rows)==0)
251
d0811661659f
		 		return;
252
d0811661659f
		 	////WPD_print("Found".count($rows)." networks.");
253
d0811661659f
		 	
254
d0811661659f
		 	foreach ($rows as $row) {
255
d0811661659f
		 		//WPD_print("SiteID: " . $row[1]);
256
d0811661659f
		 		$linkInfoArray = $definitions[$row[1]];
257
d0811661659f
		 		//WPD_print('network info '. $linkInfoArray);
258
d0811661659f
		 		$url = str_replace("%userid%",$row[2],$linkInfoArray[KEY_URL_TEMPLATE]);
259
d0811661659f
				$innerHTML = $innerHTML . "<a id='link_$row[0]' href='$url' rel='me'><img src='$plugindir/images/".$linkInfoArray[KEY_IMAGE]."' alt='".$linkInfoArray[KEY_DISPLAY_NAME]."'/></a>";
260
d0811661659f
				if($row != $rows[count($rows)-1]){
261
d0811661659f
					$innerHTML = $innerHTML."\n";
262
d0811661659f
				}
263
d0811661659f
			}
264
d0811661659f
			
265
d0811661659f
			return $innerHTML;
266
d0811661659f
		 }
267
d0811661659f
		 
268
d0811661659f
		 function generateSocialLinksPreviewInnerHTML($delimiter){
269
d0811661659f
		 	global $definitions;
270
d0811661659f
		 	global $plugindir;
271
d0811661659f
      
272
d0811661659f
		 	$rows = getSocialLinks();
273
d0811661659f
		 	if(count($rows)==0)
274
d0811661659f
		 		return;
275
d0811661659f
		 	//WPD_print("Found ".count($rows)." networks.");
276
d0811661659f
		 	
277
d0811661659f
		 	foreach ($rows as $row) {
278
d0811661659f
		 		//WPD_print("SiteID: " . $row[2]);
279
d0811661659f
		 		//var_dump($row);
280
d0811661659f
		 		$linkInfoArray = $definitions[$row[1]];
281
d0811661659f
		 		//var_dump($linkInfoArray);
282
d0811661659f
		 		//WPD_print('network info '. $linkInfoArray);
283
d0811661659f
		 		$url = str_replace("%userid%",$row[2],$linkInfoArray[KEY_URL_TEMPLATE]);
284
d0811661659f
				$innerHTML = $innerHTML . "<span id='link_$row[0]' title='$url'><img style='margin:2px' src='$plugindir/images/".$linkInfoArray[KEY_IMAGE]."' alt='".$linkInfoArray[KEY_DISPLAY_NAME]."'/></span>";
285
d0811661659f
				if($row != $rows[count($rows)-1]){
286
d0811661659f
					$innerHTML = $innerHTML.$delimiter;
287
d0811661659f
				}
288
d0811661659f
			}
289
d0811661659f
			
290
d0811661659f
			return $innerHTML;
291
d0811661659f
		 }
292
d0811661659f
		 
293
d0811661659f
		 /*
294
d0811661659f
		 function generateSocialLinksData(){
295
d0811661659f
			global $definitions;
296
d0811661659f
		 
297
d0811661659f
		 	$rows = getSocialLinks();
298
d0811661659f
		 	if(count($rows)==0)
299
d0811661659f
		 		return;
300
d0811661659f
		 	////WPD_print("Found".count($rows)." networks.");
301
d0811661659f
		 	$data = '';
302
d0811661659f
		 	foreach ($rows as $row) {
303
d0811661659f
		 		$linkInfoArray = $definitions[$row[2]];
304
d0811661659f
		 		$data += "link_$row[0],$linkInfoArray[0],$linkInfoArray[1],$linkInfoArray[4]\n";
305
d0811661659f
		 	}
306
d0811661659f
		 	return $data;
307
d0811661659f
		 	
308
d0811661659f
		 }
309
d0811661659f
		*/
310
d0811661659f
		
311
d0811661659f
		function social_links_admin_menu(){
312
d0811661659f
			global $pluginrelativedir;
313
d0811661659f
			//add_options_page('Social Links Settings', 'Social Links', 8,$pluginrelativedir.'/edit-sociallinks.php');
314
d0811661659f
			add_management_page('Social Links Settings (About Me)', 'Social Links', 8,__FILE__,'widget_social_links_settings');
315
d0811661659f
316
d0811661659f
			global $plugindir;
317
d0811661659f
			wp_enqueue_script('social-links', $plugindir . '/javascript.js',array('sack'));
318
d0811661659f
			wp_enqueue_script('scriptaculous');
319
d0811661659f
		}
320
d0811661659f
		
321
d0811661659f
		function addHeaderCode(){
322
d0811661659f
			//WPD_print("header code");
323
d0811661659f
			global $plugindir;
324
d0811661659f
			echo '<link type="text/css" rel="stylesheet" href="' . $plugindir . '/stylesheet.css" />' . "\n";
325
d0811661659f
			
326
d0811661659f
		}
327
d0811661659f
		
328
d0811661659f
	
329
d0811661659f
		
330
d0811661659f
			////WPD_print("Registering plugin");
331
d0811661659f
			
332
d0811661659f
			add_action('wp_head','addHeaderCode');
333
d0811661659f
			
334
d0811661659f
			
335
d0811661659f
			
336
d0811661659f
			//Add action to load sub menu
337
d0811661659f
			add_action('admin_menu', 'social_links_admin_menu');
338
d0811661659f
			
339
d0811661659f
			
340
d0811661659f
			
341
d0811661659f
			
342
d0811661659f
			//Add ajax callback action called from client side javascript
343
d0811661659f
			add_action('wp_ajax_social_links_add_network', 'wp_ajax_social_links_add_network' );
344
d0811661659f
			add_action('wp_ajax_social_links_delete_network', 'wp_ajax_social_links_delete_network' );
345
d0811661659f
			
346
d0811661659f
			register_sidebar_widget('Social Links', 'widget_social_links');
347
d0811661659f
			register_widget_control('Social Links', 'widget_social_links_control');
348
d0811661659f
		
349
d0811661659f
	}//End of SocialLinks class
350
d0811661659f
351
d0811661659f
352
d0811661659f
add_action('plugins_loaded','social_links_wrapper');
353
d0811661659f
354
d0811661659f
//todo handle auto db table update
355
d0811661659f
function social_links_install(){
356
d0811661659f
	//require_once('datastore.php');
357
d0811661659f
	//sl_install();
358
d0811661659f
	
359
d0811661659f
	global $wpdb;
360
d0811661659f
	
361
d0811661659f
	 //WPD_print("Installing Social Links Plugin");
362
d0811661659f
	 //echo '<div>Activation social links</div>';
363
d0811661659f
	 
364
d0811661659f
	$table_name = $wpdb->prefix . "social_links";
365
d0811661659f
	
366
d0811661659f
	// $installed_ver = get_option( "SOCIAL_LINKS_DB_VERSION" );
367
d0811661659f
368
d0811661659f
	if($wpdb->get_var("show tables like '$table_name'") != $table_name ) {
369
d0811661659f
		
370
d0811661659f
		$sql = "CREATE TABLE " . $table_name . " (
371
d0811661659f
		id mediumint(9) NOT NULL AUTO_INCREMENT,
372
d0811661659f
		network_id int not null,
373
d0811661659f
		user_info VARCHAR(55) NOT NULL,
374
d0811661659f
		sort_order int not null DEFAULT 0,
375
d0811661659f
		UNIQUE KEY id (id)
376
d0811661659f
		);";
377
d0811661659f
		
378
d0811661659f
		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
379
d0811661659f
		dbDelta($sql);
380
d0811661659f
		
381
d0811661659f
		
382
d0811661659f
		add_option("SOCIAL_LINKS_DB_VERSION", SOCIAL_LINKS_DB_VERSION);
383
d0811661659f
	}
384
d0811661659f
 }
385
d0811661659f
386
d0811661659f
387
d0811661659f
//Administration page
388
d0811661659f
$message;
389
d0811661659f
$messageClass;
390
d0811661659f
function widget_social_links_settings(){
391
d0811661659f
392
d0811661659f
	if (isset($_POST['saveorder']))
393
d0811661659f
	{
394
d0811661659f
		saveSortOrder();
395
d0811661659f
	}
396
d0811661659f
 
397
d0811661659f
398
d0811661659f
	global $definitions;
399
d0811661659f
	global $message;
400
d0811661659f
	global $messageClass;
401
d0811661659f
  global $plugindir;
402
d0811661659f
	
403
d0811661659f
	$visibility = 'hidden';
404
d0811661659f
	if(!empty($messageClass))
405
d0811661659f
		$visibility = 'visible';
406
d0811661659f
	
407
d0811661659f
	?>
408
d0811661659f
409
d0811661659f
410
d0811661659f
		<div class="wrap">
411
d0811661659f
			<h2>About Me</h2>
412
d0811661659f
			
413
d0811661659f
				
414
d0811661659f
				<div id="message" class="<?php echo $messageClass;  ?>" style="background-color: rgb(255, 251, 204);margin-top:10px;display:block;visibility:<?php echo $visibility;  ?>;width:300px"><?php echo $message;  ?></div>
415
d0811661659f
				<div style="position:relative;float:left;margin-right:20px;">
416
d0811661659f
					<h3>Add New Social Link</h3>
417
d0811661659f
					<select id='networkDropdown' onchange='selectionChanged()'>
418
d0811661659f
						<option>Select network...</option>
419
d0811661659f
						
420
d0811661659f
						<?php
421
d0811661659f
							
422
d0811661659f
							foreach ($definitions as $key => $linkInfoArray){
423
d0811661659f
								echo "<option value='$linkInfoArray[0]' instruction='$linkInfoArray[3]'>$linkInfoArray[4]</option>";
424
d0811661659f
							}
425
d0811661659f
						?>
426
d0811661659f
					</select>
427
d0811661659f
					
428
d0811661659f
					<label id='instruction'></label>
429
d0811661659f
					<br/>
430
d0811661659f
					<input type="text" id="addSettingInput" style="width:400px;" onkeydown="if(event.keyCode == 13){social_links_ajax_addNetwork(document.getElementById('networkDropdown').selectedIndex,document.getElementById('addSettingInput'),document.getElementById('responseDiv'));}">
431
d0811661659f
					<input type="button" id="addButton" value="Add" disabled=true
432
d0811661659f
						onclick="social_links_ajax_addNetwork(document.getElementById('networkDropdown').selectedIndex,document.getElementById('addSettingInput'),document.getElementById('responseDiv'));" />
433
d0811661659f
					<br/>
434
d0811661659f
				</div> 
435
d0811661659f
				
436
d0811661659f
			<form method="post" onSubmit="social_links_ajax_saveOrder()" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
437
d0811661659f
			
438
d0811661659f
				<div style="float:left;">
439
d0811661659f
					<h3>Preview</h3>
440
d0811661659f
					<div  id="displayDiv" style="width:100px;cursor:move;" class="drop_target">
441
d0811661659f
						<?php echo generateSocialLinksPreviewInnerHTML("\n");  ?>
442
d0811661659f
					</div>
443
d0811661659f
					
444
d0811661659f
					<input type="submit" id="saveOrderButton" name="saveorder" value="Save Order" style="margin-top:20px"/>
445
d0811661659f
					<input type="hidden" name="sortOrderData" id="sortOrderData"/>
446
d0811661659f
          <input type="hidden" name="callBackUrl" id="callBackUrl" value="<?php echo $plugindir ?>"/>
447
d0811661659f
				</div>
448
d0811661659f
				<div id="trash" style="float:left;position:relative;top:45px;left:25px;width:50px;height:50px;" class="drop_target">
449
d0811661659f
          <img src="<?php echo $plugindir ?>/images/trash.jpg"/>
450
d0811661659f
        </div>
451
d0811661659f
			</form>
452
d0811661659f
      <div style="clear: both;"> </div>
453
d0811661659f
      <div>
454
d0811661659f
        <p>
455
d0811661659f
          To add a new link select the network from the drop down, fill in the appropriate information and press enter.<br/>
456
d0811661659f
          To change the order they appear, rearrange the icons in the preview and click 'Save Order'. <br/>
457
d0811661659f
          To delete a link, simply drag it to the trash can.
458
d0811661659f
        </p>
459
d0811661659f
      </div>
460
d0811661659f
    </div>	
461
d0811661659f
		<script language="JavaScript">
462
d0811661659f
			createSortables();
463
d0811661659f
		</script>
464
d0811661659f
	<?php
465
d0811661659f
	
466
d0811661659f
	
467
d0811661659f
		}//End of widget_social_links_settings
468
d0811661659f
469
d0811661659f
function saveSortOrder(){
470
d0811661659f
	global $wpdb;
471
d0811661659f
	global $message;
472
d0811661659f
	global $messageClass;
473
d0811661659f
	//WPD_print("Action: " . $action);
474
d0811661659f
	//WPD_print("Sort Data: " . $sortDataOrder);
475
d0811661659f
	$sortDataOrder = !empty($_POST['sortOrderData']) ? $_POST['sortOrderData'] : '';
476
d0811661659f
	if(!empty($sortDataOrder))
477
d0811661659f
	{
478
d0811661659f
		//WPD_print("Saving order");
479
d0811661659f
		parse_str($sortDataOrder,$newSortorderArray);
480
d0811661659f
		if(count($newSortorderArray) != 0){
481
d0811661659f
			//WPD_print("List size: " . count($newSortorderArray));
482
d0811661659f
			$table_name = $wpdb->prefix . "social_links";
483
d0811661659f
			foreach($newSortorderArray["displayDiv"] as $order => $id){
484
d0811661659f
				//WPD_print('Order: '.$order.' Value: '.$id);
485
d0811661659f
				
486
d0811661659f
				$sql = 'Update ' .  $table_name . ' Set sort_order='.$order.' where id='.$id;
487
d0811661659f
				$result = $wpdb->query($wpdb->prepare($sql));
488
d0811661659f
				//WPD_print('Result for '.$sql.' is '.$result);
489
d0811661659f
					
490
d0811661659f
			}
491
d0811661659f
			$message = 'Saved links\' order.';
492
d0811661659f
		}
493
d0811661659f
		else{
494
d0811661659f
			$message = 'No items to save.';
495
d0811661659f
		}
496
d0811661659f
		$messageClass = 'updated fade';
497
d0811661659f
	}
498
d0811661659f
}
499
d0811661659f
500
d0811661659f
  
501
d0811661659f
?