[Movecommons-commits] r613 - in trunk: src wp-theme

Mario Gallegos mgallegos at ourproject.org
Wed Mar 20 05:23:16 CET 2013


Author: mgallegos
Date: 2013-03-20 05:23:16 +0100 (Wed, 20 Mar 2013)
New Revision: 613

Added:
   trunk/wp-theme/initiatives.txt
   trunk/wp-theme/mc2-form-controller.php
Modified:
   trunk/src/mc-dia-form2.js
   trunk/wp-theme/mc2-form.php
Log:
IN PROGRESS - Enhancement #488:Save registrations in CSV or similar

Modified: trunk/src/mc-dia-form2.js
===================================================================
--- trunk/src/mc-dia-form2.js	2013-03-15 23:22:33 UTC (rev 612)
+++ trunk/src/mc-dia-form2.js	2013-03-20 04:23:16 UTC (rev 613)
@@ -465,90 +465,129 @@
 	function xmlDynamicTags(tag,string){
 		var array = string.split(','),xml='';		
 		$.each(array, function(index, value) {
-			xml+="<"+tag+">"+xmlReplaceInvalidCharacters(value)+"</"+tag+">\n";
+			xml+="<"+tag+">"+xmlReplaceInvalidCharacters(value)+"</"+tag+">";
 		});
 		return xml;
 	}
+	
+	function commasToPipes(string){
+		var str = string;
+		str = str.replace(/,/g,'|');
+		return str; 
+	}
 		
 	function createInitiativeXml(){
 		if($j('#np-checkbox').val()=='S'){
-			nonProfitXml="<INITIATIVE_NON_PROFIT>YES</INITIATIVE_NON_PROFIT>\n";
+			nonProfitXml="<INITIATIVE_NON_PROFIT>YES</INITIATIVE_NON_PROFIT>";
 			if($j("#registered-non-profit").attr("checked"))
-				nonProfitXml+="<WE_ARE_OFFICIALLY_REGISTERED>"+xmlReplaceInvalidCharacters($j("#non-profit-website").val())+"</WE_ARE_OFFICIALLY_REGISTERED>\n";
+				nonProfitXml+="<WE_ARE_OFFICIALLY_REGISTERED>"+xmlReplaceInvalidCharacters($j("#non-profit-website").val())+"</WE_ARE_OFFICIALLY_REGISTERED>";
 			if($j("#open-accounting").attr("checked"))
-				nonProfitXml+="<WE_HAVE_WEBPAGE_WHERE_OUR_ACCOUNTING_IS_PUBLIC>"+xmlReplaceInvalidCharacters($j("#open-accounting-website").val())+"</WE_HAVE_WEBPAGE_WHERE_OUR_ACCOUNTING_IS_PUBLIC>\n";
+				nonProfitXml+="<WE_HAVE_WEBPAGE_WHERE_OUR_ACCOUNTING_IS_PUBLIC>"+xmlReplaceInvalidCharacters($j("#open-accounting-website").val())+"</WE_HAVE_WEBPAGE_WHERE_OUR_ACCOUNTING_IS_PUBLIC>";
 			if($j("#accept-donations").attr("checked"))
-				nonProfitXml+="<WE_HAVE_A_WEBPAGE_TO_RECEIVE_ONLINE_DONATIONS>"+xmlReplaceInvalidCharacters($j("#donation-website").val())+"</WE_HAVE_A_WEBPAGE_TO_RECEIVE_ONLINE_DONATIONS>\n";		
+				nonProfitXml+="<WE_HAVE_A_WEBPAGE_TO_RECEIVE_ONLINE_DONATIONS>"+xmlReplaceInvalidCharacters($j("#donation-website").val())+"</WE_HAVE_A_WEBPAGE_TO_RECEIVE_ONLINE_DONATIONS>";		
 		}else{
-			nonProfitXml="<INITIATIVE_NON_PROFIT>NO</INITIATIVE_NON_PROFIT>\n";
+			nonProfitXml="<INITIATIVE_NON_PROFIT>NO</INITIATIVE_NON_PROFIT>";
 		}
 		
 		if($j('#rp-checkbox').val()=='S'){
-			reproducibleXml="<INITIATIVE_REPRODUCIBLE>YES</INITIATIVE_REPRODUCIBLE>\n";
+			reproducibleXml="<INITIATIVE_REPRODUCIBLE>YES</INITIATIVE_REPRODUCIBLE>";
 			if($j("#terms-of-use").attr("checked"))
-				reproducibleXml+="<WE_HAVE_TERMS_OF_USE_OF_OUR_CONTENTS>"+xmlReplaceInvalidCharacters($j("#terms-of-use-website").val())+"</WE_HAVE_TERMS_OF_USE_OF_OUR_CONTENTS>\n";
+				reproducibleXml+="<WE_HAVE_TERMS_OF_USE_OF_OUR_CONTENTS>"+xmlReplaceInvalidCharacters($j("#terms-of-use-website").val())+"</WE_HAVE_TERMS_OF_USE_OF_OUR_CONTENTS>";
 			if($j("#creative-commons").attr("checked")) 
-				reproducibleXml+="<CREATIVE_COMMONS_LICENSE_FOR_SHARING_OUR_CONTENT>"+xmlReplaceInvalidCharacters($j("#creative-commons-website").val())+"</CREATIVE_COMMONS_LICENSE_FOR_SHARING_OUR_CONTENT>\n";
+				reproducibleXml+="<CREATIVE_COMMONS_LICENSE_FOR_SHARING_OUR_CONTENT>"+xmlReplaceInvalidCharacters($j("#creative-commons-website").val())+"</CREATIVE_COMMONS_LICENSE_FOR_SHARING_OUR_CONTENT>";
 			if($j("#other-license").attr("checked"))
-				reproducibleXml+="<OTHER_LICENSE_FOR_SHARING_OUR_CONTENT>"+xmlReplaceInvalidCharacters($j("#other-license-website").val())+"</OTHER_LICENSE_FOR_SHARING_OUR_CONTENT>\n";		
-			reproducibleXml+="<WE_PROVIDE_PUBLIC_DOCUMENTATION_ABOUT>\n";
+				reproducibleXml+="<OTHER_LICENSE_FOR_SHARING_OUR_CONTENT>"+xmlReplaceInvalidCharacters($j("#other-license-website").val())+"</OTHER_LICENSE_FOR_SHARING_OUR_CONTENT>";		
 			if($j("#organization-structure").attr("checked"))
-				reproducibleXml+="<PUBLIC_DOCUMENTATION>OUR_ORGANIZATION</PUBLIC_DOCUMENTATION>\n";			
+				reproducibleXml+="<OUR_ORGANIZATION>YES</OUR_ORGANIZATION>";	
+			else
+				reproducibleXml+="<OUR_ORGANIZATION>NO</OUR_ORGANIZATION>";
 			if($j("#internal-procedures").attr("checked"))
-				reproducibleXml+="<PUBLIC_DOCUMENTATION>OUR_INTERNAL_PROCEDURES</PUBLIC_DOCUMENTATION>\n";			
+				reproducibleXml+="<OUR_INTERNAL_PROCEDURES>YES</OUR_INTERNAL_PROCEDURES>";	
+			else
+				reproducibleXml+="<OUR_INTERNAL_PROCEDURES>NO</OUR_INTERNAL_PROCEDURES>";	
 			if($j("#list-members").attr("checked"))
-				reproducibleXml+="<PUBLIC_DOCUMENTATION>OUR_LIST_OF_MEMBERS</PUBLIC_DOCUMENTATION>\n";			
+				reproducibleXml+="<OUR_LIST_OF_MEMBERS>YES</OUR_LIST_OF_MEMBERS>";
+			else
+				reproducibleXml+="<OUR_LIST_OF_MEMBERS>NO</OUR_LIST_OF_MEMBERS>";
 			if($j("#funding-sources").attr("checked"))
-				reproducibleXml+="<PUBLIC_DOCUMENTATION>OUR_FUNDING_SOURCES</PUBLIC_DOCUMENTATION>\n";			
-			reproducibleXml+="</WE_PROVIDE_PUBLIC_DOCUMENTATION_ABOUT>\n";
+				reproducibleXml+="<OUR_FUNDING_SOURCES>YES</OUR_FUNDING_SOURCES>";
+			else
+				reproducibleXml+="<OUR_FUNDING_SOURCES>NO</OUR_FUNDING_SOURCES>";
+			/*reproducibleXml+="<WE_PROVIDE_PUBLIC_DOCUMENTATION_ABOUT>";
+			if($j("#organization-structure").attr("checked"))
+				reproducibleXml+="<PUBLIC_DOCUMENTATION>OUR_ORGANIZATION</PUBLIC_DOCUMENTATION>";			
+			if($j("#internal-procedures").attr("checked"))
+				reproducibleXml+="<PUBLIC_DOCUMENTATION>OUR_INTERNAL_PROCEDURES</PUBLIC_DOCUMENTATION>";			
+			if($j("#list-members").attr("checked"))
+				reproducibleXml+="<PUBLIC_DOCUMENTATION>OUR_LIST_OF_MEMBERS</PUBLIC_DOCUMENTATION>";			
+			if($j("#funding-sources").attr("checked"))
+				reproducibleXml+="<PUBLIC_DOCUMENTATION>OUR_FUNDING_SOURCES</PUBLIC_DOCUMENTATION>";			
+			reproducibleXml+="</WE_PROVIDE_PUBLIC_DOCUMENTATION_ABOUT>";
+			*/			
 		}else{
-			reproducibleXml="<INITIATIVE_REPRODUCIBLE>NO</INITIATIVE_REPRODUCIBLE>\n";
+			reproducibleXml="<INITIATIVE_REPRODUCIBLE>NO</INITIATIVE_REPRODUCIBLE>";
 		}
 		
 		if($j('#gr-checkbox').val()=='S'){
-			grassrootsXml="<INITIATIVE_GRASSROOTS>YES</INITIATIVE_GRASSROOTS>\n";
+			grassrootsXml="<INITIATIVE_GRASSROOTS>YES</INITIATIVE_GRASSROOTS>";
 			if($j("#decisions-general-assemblies").attr("checked"))
-				grassrootsXml+="<WE_TAKE_DECISIONS_MAINLY_THROUGH_GENERAL_ASSEMBLIES>YES</WE_TAKE_DECISIONS_MAINLY_THROUGH_GENERAL_ASSEMBLIES>\n";
+				grassrootsXml+="<WE_TAKE_DECISIONS_MAINLY_THROUGH_GENERAL_ASSEMBLIES>YES</WE_TAKE_DECISIONS_MAINLY_THROUGH_GENERAL_ASSEMBLIES>";
 			else
-				grassrootsXml+="<WE_TAKE_DECISIONS_MAINLY_THROUGH_GENERAL_ASSEMBLIES>NO</WE_TAKE_DECISIONS_MAINLY_THROUGH_GENERAL_ASSEMBLIES>\n";
+				grassrootsXml+="<WE_TAKE_DECISIONS_MAINLY_THROUGH_GENERAL_ASSEMBLIES>NO</WE_TAKE_DECISIONS_MAINLY_THROUGH_GENERAL_ASSEMBLIES>";
 			if($j("#representatives-democratically").attr("checked"))
-				grassrootsXml+="<WE_HAVE_REPRESENTATIVES_CHOSEN_DEMOCRATICALLY>YES</WE_HAVE_REPRESENTATIVES_CHOSEN_DEMOCRATICALLY>\n";
+				grassrootsXml+="<WE_HAVE_REPRESENTATIVES_CHOSEN_DEMOCRATICALLY>YES</WE_HAVE_REPRESENTATIVES_CHOSEN_DEMOCRATICALLY>";
 			else
-				grassrootsXml+="<WE_HAVE_REPRESENTATIVES_CHOSEN_DEMOCRATICALLY>NO</WE_HAVE_REPRESENTATIVES_CHOSEN_DEMOCRATICALLY>\n";
+				grassrootsXml+="<WE_HAVE_REPRESENTATIVES_CHOSEN_DEMOCRATICALLY>NO</WE_HAVE_REPRESENTATIVES_CHOSEN_DEMOCRATICALLY>";
 			if($j("#decisions-voting").attr("checked"))
-				grassrootsXml+="<WE_TAKE_DECISIONS_THROUGH>MAJORITY_VOTING</WE_TAKE_DECISIONS_THROUGH>\n";
+				grassrootsXml+="<WE_TAKE_DECISIONS_THROUGH>MAJORITY_VOTING</WE_TAKE_DECISIONS_THROUGH>";
 			else if ($j("#decisions-consensus").attr("checked"))
-				grassrootsXml+="<WE_TAKE_DECISIONS_THROUGH>CONSENSUS</WE_TAKE_DECISIONS_THROUGH>\n";						
+				grassrootsXml+="<WE_TAKE_DECISIONS_THROUGH>CONSENSUS</WE_TAKE_DECISIONS_THROUGH>";						
 		}else{
-			grassrootsXml="<INITIATIVE_GRASSROOTS>NO</INITIATIVE_GRASSROOTS>\n";
+			grassrootsXml="<INITIATIVE_GRASSROOTS>NO</INITIATIVE_GRASSROOTS>";
 		}
 		
 		if($j('#rc-checkbox').val()=='S'){
-			reinforceCommonsXml="<INITIATIVE_REINFORCE_THE_COMMONS>YES</INITIATIVE_REINFORCE_THE_COMMONS>\n";
+			reinforceCommonsXml="<INITIATIVE_REINFORCE_THE_COMMONS>YES</INITIATIVE_REINFORCE_THE_COMMONS>";
 			if($j('#mc-form-icon-rc').attr('src')=='/mc/0.1/images/rcec60.png')
-				reinforceCommonsXml+="<MAIN_FOCUS_OF_THE_INITIATIVE>NATURE_COMMONS</MAIN_FOCUS_OF_THE_INITIATIVE>\n";
+				reinforceCommonsXml+="<MAIN_FOCUS_OF_THE_INITIATIVE>NATURE COMMONS</MAIN_FOCUS_OF_THE_INITIATIVE>";
 			else if($j('#mc-form-icon-rc').attr('src')=='/mc/0.1/images/rcbo60.png')
-				reinforceCommonsXml+="<MAIN_FOCUS_OF_THE_INITIATIVE>BODY_HEALTH_COMMONS</MAIN_FOCUS_OF_THE_INITIATIVE>\n";
+				reinforceCommonsXml+="<MAIN_FOCUS_OF_THE_INITIATIVE>BODY HEALTH COMMONS</MAIN_FOCUS_OF_THE_INITIATIVE>";
 			else if($j('#mc-form-icon-rc').attr('src')=='/mc/0.1/images/rcto60.png')
-				reinforceCommonsXml+="<MAIN_FOCUS_OF_THE_INITIATIVE>TOWN_COMMUNITY_SOCIETY_COMMONS</MAIN_FOCUS_OF_THE_INITIATIVE>\n";
+				reinforceCommonsXml+="<MAIN_FOCUS_OF_THE_INITIATIVE>TOWN COMMUNITY SOCIETY_COMMONS</MAIN_FOCUS_OF_THE_INITIATIVE>";
 			else
-				reinforceCommonsXml+="<MAIN_FOCUS_OF_THE_INITIATIVE>DIGITAL_COMMONS</MAIN_FOCUS_OF_THE_INITIATIVE>\n";
+				reinforceCommonsXml+="<MAIN_FOCUS_OF_THE_INITIATIVE>DIGITAL COMMONS</MAIN_FOCUS_OF_THE_INITIATIVE>";
 		}else{
-			reinforceCommonsXml="<INITIATIVE_REINFORCE_THE_COMMONS>NO</INITIATIVE_REINFORCE_THE_COMMONS>\n";
+			reinforceCommonsXml="<INITIATIVE_REINFORCE_THE_COMMONS>NO</INITIATIVE_REINFORCE_THE_COMMONS>";
 		}
 		
-		xmlDoc = "<INITIATIVE>\n" 
-					+"<NAME>"+xmlReplaceInvalidCharacters($j("#ininame").val())+"</NAME>\n"+
-					"<WEB_ADDRESS>"+xmlReplaceInvalidCharacters($j("#url").val())+"</WEB_ADDRESS>\n"+
-					"<LANGUAGES>\n"+xmlDynamicTags('LANGUAGE',$j("#languages").val())+"</LANGUAGES>\n"+
-					"<KEYWORDS>\n"+xmlDynamicTags('KEYWORD',$j("#keywords").val())+"</KEYWORDS>\n"+
-					"<LOCATION>"+xmlReplaceInvalidCharacters($j("#location").val())+"</LOCATION>\n"+
+		xmlDoc = "<INITIATIVE>" 
+					+"<NAME>"+xmlReplaceInvalidCharacters($j("#ininame").val())+"</NAME>"+
+					"<WEB_ADDRESS>"+xmlReplaceInvalidCharacters($j("#url").val())+"</WEB_ADDRESS>"+
+					//"<LANGUAGES>"+xmlDynamicTags('LANGUAGE',$j("#languages").val())+"</LANGUAGES>"+
+					"<LANGUAGES>"+commasToPipes('LANGUAGE',$j("#languages").val())+"</LANGUAGES>"+
+					//"<KEYWORDS>"+xmlDynamicTags('KEYWORD',$j("#keywords").val())+"</KEYWORDS>"+
+					"<KEYWORDS>"+commasToPipes('KEYWORD',$j("#keywords").val())+"</KEYWORDS>"+
+					"<LOCATION>"+xmlReplaceInvalidCharacters($j("#location").val())+"</LOCATION>"+
 					nonProfitXml+
 					reproducibleXml+
 					grassrootsXml+
 					reinforceCommonsXml+
-				"</INITIATIVE>";		
-		alert(xmlDoc);
+				"</INITIATIVE>";	
+		
+		$j.ajax({
+			url: "/wp-content/themes/mc/mc2-form-controller.php",
+			type: "POST",
+			processData: false,
+			contentType: "text/xml",
+			beforeSend: function(){
+				//$('#loader').show();					 		 				
+	 		},  	
+			data: $j.createXML(xmlDoc),			
+			success: function(xmlData) {				
+				alert("Dev msg: Your data has been successfully saved!!");
+			}
+		});
+		
 	}
 	    
     $j('#submit_first').click(function(){

Added: trunk/wp-theme/initiatives.txt
===================================================================

Added: trunk/wp-theme/mc2-form-controller.php
===================================================================
--- trunk/wp-theme/mc2-form-controller.php	                        (rev 0)
+++ trunk/wp-theme/mc2-form-controller.php	2013-03-20 04:23:16 UTC (rev 613)
@@ -0,0 +1,4 @@
+<?php
+
+
+?>
\ No newline at end of file

Modified: trunk/wp-theme/mc2-form.php
===================================================================
--- trunk/wp-theme/mc2-form.php	2013-03-15 23:22:33 UTC (rev 612)
+++ trunk/wp-theme/mc2-form.php	2013-03-20 04:23:16 UTC (rev 613)
@@ -397,6 +397,7 @@
 			</div>			
 			<div class="label2" style="margin-left: 185px;float: left;font-size: 14px;"><?php _e("Include this code in the web of your collective:", "mc"); ?></div>
 			<textarea style="margin-left: 185px;margin-top: 20px;margin-bottom: 20px;" rows="4" cols="68" onfocus="this.select()" class="mc-icon88x31-code" id="mc-intro-textarea">&lt;div id="move-commons-badge"&gt;&lt;div xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:mc="http://movecommons.org/ns#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" about="waveclick.com.sv" typeof="mc:Collective"&gt;&lt;/div&gt;&lt;div property="foaf:name" content="Waveclick"&gt;&lt;/div&gt;&lt;div rel="foaf:homepage" href="waveclick.com.sv"&gt;&lt;/div&gt;&lt;div rel="mc:moveCommonsType" resource="[mc:NonProfit]"&gt;&lt;/div&gt;&lt;div rel="mc:moveCommonsType" resource="[mc:Reproducible]"&gt;&lt;/div&gt;&lt;div rel="mc:moveCommonsType" resource="[mc:ReinforcesOtherAims]"&gt;&lt;/div&gt;&lt;div rel="mc:moveCommonsType" resource="[mc:Representative]"&gt;&lt;/div&gt;&lt;div about="#dd" typeof="skos:Concept"&gt;&lt;/div&gt;&lt;div about="#dd" typeof="skos:Concept"&gt;&lt;/div&gt;&lt;a href="http://movecommons.org/en/np-rp-ro-rs/0.1/"&gt;&lt;img src="http://movecommons.org/mc/0.1/images/np-rp-ro-rs-88x31-0.1.png" alt="Move Commons Non-Profit, Reproducible, Reinforcing Other Aims, Representative" /&gt;&lt;/a&gt;&lt;p&gt;Move Commons Non-Profit, Reproducible, Reinforcing Other Aims, Representative&lt;/p&gt;&lt;/div&gt;</textarea>
+			<div class="label2" style="margin-left: 185px;float: left;font-size: 14px;"><a href="http://movecommons.org/wp-content/themes/mc/initiatives.txt">Click here to download the CVS file.</a></div>
 			<div>
 				<button class="submit buttonp" style="left: 710px;" type="submit" name="p_submit_sixth" id="p_submit_sixth"><?php _e("Previous", "mc"); ?></button>
 			</div>				




More information about the Movecommons-commits mailing list