Created
September 13, 2010 01:19
-
-
Save ppshein/576683 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent output="true"> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="getManager" access="public" output="true" returntype="any"> | |
<cfreturn variables.mainManager /> | |
</cffunction> | |
<cffunction name="setManager" access="public" output="true" returntype="void"> | |
<cfargument name="mainManager" type="any" required="true" /> | |
<cfset variables.mainManager = arguments.mainManager /> | |
</cffunction> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="getPreferencesManager" access="public" output="true" returntype="any"> | |
<cfreturn variables.preferencesManager /> | |
</cffunction> | |
<cffunction name="setPreferencesManager" access="public" output="true" returntype="void"> | |
<cfargument name="preferencesManager" type="any" required="true" /> | |
<cfset variables.preferencesManager = arguments.preferencesManager /> | |
</cffunction> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="getId" access="public" output="true" returntype="any"> | |
<cfreturn variables.id /> | |
</cffunction> | |
<cffunction name="setId" access="public" output="true" returntype="void"> | |
<cfargument name="id" type="any" required="true" /> | |
<cfset variables.id = arguments.id /> | |
</cffunction> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="getName" access="public" output="true" returntype="string"> | |
<cfreturn variables.name /> | |
</cffunction> | |
<cffunction name="setName" access="public" output="true" returntype="void"> | |
<cfargument name="name" type="string" required="true" /> | |
<cfset variables.name = arguments.name /> | |
</cffunction> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="getPackage" access="public" output="true" returntype="any"> | |
<cfreturn variables.package /> | |
</cffunction> | |
<cffunction name="setPackage" access="public" output="true" returntype="void"> | |
<cfargument name="package" type="any" required="true" /> | |
<cfset variables.package = arguments.package /> | |
</cffunction> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="getSettingsPath" access="public" output="true" returntype="any"> | |
<cfreturn getManager().getBlog().getId() & "/" & getPackage() /> | |
</cffunction> | |
<cffunction name="getAssetPath" access="public" output="true" returntype="any"> | |
<cfreturn getManager().getBlog().getBasePath() & "assets/plugins/" & getPluginDirName() & "/" /> | |
</cffunction> | |
<cffunction name="getAdminAssetPath" access="public" output="true" returntype="any"> | |
<cfreturn getManager().getBlog().getBasePath() & "admin/assets/plugins/" & getPluginDirName() & "/" /> | |
</cffunction> | |
<cffunction name="getPluginDirName" access="private" output="true" returntype="any"> | |
<cfset var name = getMetaData(this).name /> | |
<cfset var dir = ListGetAt(name, ListLen(name, ".")-1, ".")> | |
<cfreturn dir /> | |
</cffunction> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="initSettings" access="public" output="true" returntype="void"> | |
<cfset var key = "" /> | |
<cfset variables.settings = StructNew() /> | |
<cfloop collection="#arguments#" item="key"> | |
<cfset variables.settings[key] = getPreferencesManager().get(getSettingsPath(), key, arguments[key]) /> | |
</cfloop> | |
</cffunction> | |
<cffunction name="setSettings" access="public" output="true" returntype="void"> | |
<cfset var key = "" /> | |
<cfloop collection="#arguments#" item="key"> | |
<cfset variables.settings[key] = arguments[key] /> | |
</cfloop> | |
</cffunction> | |
<cffunction name="getSetting" access="public" output="true" returntype="any"> | |
<cfargument name="key" type="any" required="true" /> | |
<cfreturn variables.settings[arguments.key] /> | |
</cffunction> | |
<cffunction name="persistSettings" access="public" output="true" returntype="void"> | |
<cfset var key = "" /> | |
<cfloop collection="#variables.settings#" item="key"> | |
<cfset getPreferencesManager().put(getSettingsPath(), key, variables.settings[key]) /> | |
</cfloop> | |
</cffunction> | |
</cfcomponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent extends="BasePlugin" output="yes"> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="init" access="public" output="true" returntype="any"> | |
<cfargument name="mainManager" type="any" required="true" /> | |
<cfargument name="preferences" type="any" required="true" /> | |
<cfset setManager(arguments.mainManager) /> | |
<cfset setPreferencesManager(arguments.preferences) /> | |
<cfset setPackage("com/ppshein/facebookLike") /> | |
<cfset path = getManager().getBlog().getBasePath() /> | |
<cfset variables.facebookLikeSelected = getPreferencesManager().get(path,"cgi.query_stringSelected","") /> | |
<cfreturn this/> | |
</cffunction> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="setup" hint="This is run when a plugin is activated" access="public" output="true" returntype="any"> | |
<cfset path = getManager().getBlog().getBasePath() /> | |
<cfset getPreferencesManager().put(path,"facebookLikeSelected","") /> | |
<cfreturn "The facebookLike plugin activated! Would you like to <a href='generic_settings.cfm?event=showfacebookLikeSettings&owner=facebookLike&selected=showfacebookLikeSettings'>configure it now</a>?" /> | |
</cffunction> | |
<cffunction name="unsetup" hint="This is run when a plugin is de-activated" access="public" output="true" returntype="any"> | |
<cfreturn "facebookLike plugin de-activated."/> | |
</cffunction> | |
<cffunction name="upgrade" hint="This is run when upgrading from a previous version with auto-install" output="true" returntype="any"> | |
<cfreturn "Upgrade complete." /> | |
</cffunction> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="handleEvent" hint="Asynchronous event handling" access="public" output="true" returntype="any"> | |
<cfargument name="event" type="any" required="true" /> | |
<cfreturn /> | |
</cffunction> | |
<!--- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ---> | |
<cffunction name="processEvent" hint="Synchronous event handling" access="public" output="yes" returntype="any"> | |
<cfargument name="event" type="any" required="true" /> | |
<cfset var facebookLike = "" /> | |
<cfset var outputData = "" /> | |
<cfset var link = "" /> | |
<cfset var page = "" /> | |
<cfset var data = ""/> | |
<cfset var path = "" /> | |
<cfset var admin = "" /> | |
<cfset var eventName = arguments.event.name /> | |
<cfif eventName EQ "beforePostContentEnd"> | |
<cfset outputData = arguments.event.getOutputData() /> | |
<cfset blog = request.blogManager.getBlog() /> | |
<cfset facebookLikeLayout = variables.facebookLikeSelected> | |
<cfsavecontent variable="content"><cfoutput> | |
<div id="facebookLike"><span></span> | |
<iframe src="http://www.facebook.com/plugins/like.php?href=#arguments.event.contextData.currentPost.getPermalink()#&layout=#facebookLikeLayout#&show_faces=true&width=450&action=like&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe> | |
</div> | |
</cfoutput></cfsavecontent> | |
<cfset arguments.event.setOutputData(outputData & variables.content) /> | |
<cfelseif eventName EQ "settingsNav"> | |
<cfset link = structnew() /> | |
<cfset link.owner = "facebookLike"> | |
<cfset link.page = "settings" /> | |
<cfset link.title = "facebookLike" /> | |
<cfset link.eventName = "showfacebookLikeSettings" /> | |
<cfset arguments.event.addLink(link)> | |
<!--- admin event ---> | |
<cfelseif eventName EQ "showfacebookLikeSettings"> | |
<cfset data = arguments.event.getData() /> | |
<cfif structkeyexists(data.externaldata,"apply")> | |
<cfset variables.facebookLikeSelected = data.externaldata.facebookLikeSelected /> | |
<cfset path = getManager().getBlog().getBasePath() /> | |
<cfset getPreferencesManager().put(path,"facebookLikeSelected",variables.facebookLikeSelected) /> | |
<cfset data.message.setstatus("success") /> | |
<cfset data.message.setType("settings") /> | |
<cfset data.message.settext("facebookLike updated successfully")/> | |
</cfif> | |
<cfsavecontent variable="page"> | |
<cfinclude template="admin/settingsForm.cfm"> | |
</cfsavecontent> | |
<!--- change message ---> | |
<cfset data.message.setTitle("facebookLike Settings") /> | |
<cfset data.message.setData(page) /> | |
</cfif> | |
<cfreturn arguments.event /> | |
</cffunction> | |
</cfcomponent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<plugin id="com.ppshein.facebookLike" name="facebookLike" version="1.0.0" provider-name="ppshein.net" class="facebookLike.Handler"> | |
<description><![CDATA[ facebookLike is a plugin that the Like button lets a user share your content with friends on Facebook. | |
</br > | |
</br > | |
Written by <a href="http://ppshein.net">ppshein</a><br/>]]></description> | |
<requiresVersion match="greaterOrEqual">1</requiresVersion> | |
<listens> | |
<event name="beforePostContentEnd" type="synch" priority="6" /> | |
</listens> | |
<listensAdmin> | |
<event name="settingsNav" type="synch" priority="6" /> | |
<event name="showfacebookLikeSettings" type="synch" priority="6" /> | |
</listensAdmin> | |
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
<cfset blog = request.blogManager.getBlog() /> | |
<cfset facebookLikeLayout = variables.facebookLikeSelected> | |
<form method="post" action="#cgi.script_name#"> | |
<fieldset> | |
<legend>facebookLike settings</legend> | |
<p> | |
Layout Style : <br> | |
<select id="facebookLikeSelected" name="facebookLikeSelected"> | |
<option value="standard" <cfif facebookLikeLayout EQ "standard">selected</cfif>>standard</option> | |
<option value="button_count" <cfif facebookLikeLayout EQ "button_count">selected</cfif>>button_count</option> | |
<option value="box_count" <cfif facebookLikeLayout EQ "box_count">selected</cfif>>box_count</option> | |
</select> | |
</p> | |
</fieldset> | |
<div class="actions"> | |
<input type="submit" class="primaryAction" value="Submit"/> | |
<input type="hidden" value="event" name="action" /> | |
<input type="hidden" value="showfacebookLikeSettings" name="event" /> | |
<input type="hidden" value="true" name="apply" /> | |
<input type="hidden" value="facebookLike" name="selected" /> | |
</div> | |
</form> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment