Author: lombardot Date: 2010-04-26 16:26:54 +0200 (Mon, 26 Apr 2010) New Revision: 29261
Added: plugins/sfEmailMeAFireShotPlugin/config/ plugins/sfEmailMeAFireShotPlugin/config/app.yml plugins/sfEmailMeAFireShotPlugin/lib/ plugins/sfEmailMeAFireShotPlugin/lib/form/ plugins/sfEmailMeAFireShotPlugin/lib/form/sfEmailMeAFireShotEmailForm.php plugins/sfEmailMeAFireShotPlugin/lib/helper/ plugins/sfEmailMeAFireShotPlugin/lib/helper/sfEmailMeAFireShotHelper.php plugins/sfEmailMeAFireShotPlugin/modules/ plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/ plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/actions/ plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/actions/actions.class.php plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/templates/ plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/templates/indexSuccess.php plugins/sfEmailMeAFireShotPlugin/web/ plugins/sfEmailMeAFireShotPlugin/web/js/ plugins/sfEmailMeAFireShotPlugin/web/js/fsapi.js Log: [sfEmailMeAFireShotPlugin] lombardot first commit Added: plugins/sfEmailMeAFireShotPlugin/config/app.yml =================================================================== --- plugins/sfEmailMeAFireShotPlugin/config/app.yml (rev 0) +++ plugins/sfEmailMeAFireShotPlugin/config/app.yml 2010-04-26 14:26:54 UTC (rev 29261) @@ -0,0 +1,6 @@ +all: + sfEmailMeAFireShot: + apiKey: #http://screenshot-program.com/fireshot/api_key.php + localhost: GO361F03J00G071A6ICIJVC629E0IG86JBO0NKTU + + \ No newline at end of file Added: plugins/sfEmailMeAFireShotPlugin/lib/form/sfEmailMeAFireShotEmailForm.php =================================================================== --- plugins/sfEmailMeAFireShotPlugin/lib/form/sfEmailMeAFireShotEmailForm.php (rev 0) +++ plugins/sfEmailMeAFireShotPlugin/lib/form/sfEmailMeAFireShotEmailForm.php 2010-04-26 14:26:54 UTC (rev 29261) @@ -0,0 +1,23 @@ +<?php + +class sfEmailMeAFireShotEmailForm extends sfForm { + + public function configure(){ + $this->setWidgets(array( + 'subject'=>new sfWidgetFormInput(), + 'content'=>new sfWidgetFormTextarea(), + 'capture'=>new sfWidgetFormTextarea(), + )); + + $this->setValidators(array( + 'subject'=>new sfValidatorString(array('required'=>true)), + 'content'=>new sfValidatorString(array('required'=>true)), + 'capture'=>new sfValidatorString(array('required'=>true)), + )); + + $this->widgetSchema->setNameFormat('email_me_fireshot[%s]'); + } + + +} +?> \ No newline at end of file Added: plugins/sfEmailMeAFireShotPlugin/lib/helper/sfEmailMeAFireShotHelper.php =================================================================== --- plugins/sfEmailMeAFireShotPlugin/lib/helper/sfEmailMeAFireShotHelper.php (rev 0) +++ plugins/sfEmailMeAFireShotPlugin/lib/helper/sfEmailMeAFireShotHelper.php 2010-04-26 14:26:54 UTC (rev 29261) @@ -0,0 +1,51 @@ +<?php + +function link_sfEmailMeAFireShot($content,$action="email"){ + return content_tag('span', + content_tag('a',$content,array('onclick'=>'shotAnd("'.$action.'"); return false;','href'=>'#')), + array('id'=>'sfEmailMeAFireShot')); + +} + + +/** + * Add js + */ +function include_sfEmailMeAFireShot_js(){ + $apiKey=get_sfEmailMeAFireShot_apiKey(); + echo javascript_include_tag('/sfEmailMeAFireShotPlugin/js/fsapi.js'); + echo javascript_tag('$(document).ready(function(){ + FireShotAPI.Key ="'.$apiKey.'"; + if(!FireShotAPI.isWindows()){ $("#sfEmailMeAFireShot").hide(); } + if(!FireShotAPI.isFirefox()){ $("#sfEmailMeAFireShot").hide(); } + });'); + echo javascript_tag(' + function shotAnd(action){ + //Test si install + if (typeof(FireShotAPI) != "undefined" && FireShotAPI.isAvailable()){ + if(action=="email") + FireShotAPI.emailPage(true); + + + }else{ + $("#sfEmailMeAFireShot").html( "<b>Not installed</b>, " + + "<a href=\'javascript:FireShotAPI.installPlugin()\'>Install plugin now</a>"); + } + } + '); +} + + +function get_sfEmailMeAFireShot_apiKey(){ + $request=sfContext::getInstance()->getRequest(); + $keys=sfConfig::get('app_sfEmailMeAFireShot_apiKey',array()); + if(array_key_exists($request->getHost(),$keys)){ + return $keys[$request->getHost()]; + } + if(array_key_exists($_SERVER["SERVER_ADDR"],$keys)){ + return $keys[$_SERVER["SERVER_ADDR"]]; + } + return ''; +} + +?> \ No newline at end of file Added: plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/actions/actions.class.php =================================================================== --- plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/actions/actions.class.php (rev 0) +++ plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/actions/actions.class.php 2010-04-26 14:26:54 UTC (rev 29261) @@ -0,0 +1,11 @@ +<?php + +class sfEmailMeAFireShotActions extends sfActions{ + + public function executeIndex(sfWebRequest $request){ + throw new Exception('Getting clipboard content in dev'); + $this->form=$form=new sfEmailMeAFireShotEmailForm(); + } + +} +?> \ No newline at end of file Added: plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/templates/indexSuccess.php =================================================================== --- plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/templates/indexSuccess.php (rev 0) +++ plugins/sfEmailMeAFireShotPlugin/modules/sfEmailMeAFireShot/templates/indexSuccess.php 2010-04-26 14:26:54 UTC (rev 29261) @@ -0,0 +1,3 @@ +<?php + +?> \ No newline at end of file Added: plugins/sfEmailMeAFireShotPlugin/web/js/fsapi.js =================================================================== --- plugins/sfEmailMeAFireShotPlugin/web/js/fsapi.js (rev 0) +++ plugins/sfEmailMeAFireShotPlugin/web/js/fsapi.js 2010-04-26 14:26:54 UTC (rev 29261) @@ -0,0 +1,163 @@ + /* FireShotAPI + ** + ** simple API for FireShot automation (capturing web pages using JavaScript).** + ** Code licensed under Mozill Public License ** + ** https://addons.mozilla.org/en-US/firefox/versions/license/69512 ** + ** ** + ** Author: Evgeny Suslikov, http://screenshot-program.com/fireshot ** + ** */ + +var cFSEdit = 0; +var cFSSave = 1; +var cFSClipboard = 2; +var cFSEMail = 3; +var cFSExternal = 4; +var cFSUpload = 5; +var cFSPrint = 7; + +var FireShotAPI = +{ + Key : "", // This key should be set up before using the API + AutoInstall: true, // Set this variable to false to switch off addon auto-installation + + // Check silently whether the addon is available at the client's PC, returns *true* if everything is OK. Otherwise returns *false*. + isAvailable : function() + { + if (!this.isWindows() || !this.isFirefox()) return false; + + var element = document.createElement("FireShotDataElement"); + element.setAttribute("FSAvailable", false); + document.documentElement.appendChild(element); + + var evt = document.createEvent("Events"); + evt.initEvent("checkFSAvailabilityEvt", true, false); + + element.dispatchEvent(evt); + + return element.getAttribute("FSAvailable") == "true"; + }, + + // Installs plugin + installPlugin : function() + { + if (!this.isWindows() || !this.isFirefox()) + { + this.errorOnlyFirefoxAtWindows(); + return; + } + else + { + var xpi = new Object(); + xpi['FireShot'] = "http://screenshot-program.com/fireshot.xpi"; + InstallTrigger.install(xpi, FireShotAPI.installationDone); + } + }, + + // Callback function seems to be not working properly + installationDone : function(name, result) + { + if (result != 0 && result != 999) + alert("The install didn't seem to work, you could maybe try " + + "a manual install instead.\nFailure code was " + result + "."); + else + alert("Installation complete, please restart your browser."); + }, + + // Capture web page and perform desired action + capturePage : function(EntirePage, Action, Key) + { + if (this.AutoInstall && !this.isAvailable()) + { + this.installPlugin(); + return; + } + + var element = document.createElement("FireShotDataElement"); + element.setAttribute("Entire", EntirePage); + element.setAttribute("Action", Action); + element.setAttribute("Key", Key); + document.documentElement.appendChild(element); + + var evt = document.createEvent("Events"); + evt.initEvent("capturePageEvt", true, false); + + element.dispatchEvent(evt); + }, + + // Capture web page (Entire = true for capturing the web page entirely) and *edit* + editPage : function(Entire) + { + this.capturePage(Entire, cFSEdit, this.Key); + }, + + // Capture web page and *save to disk* + savePage : function(Entire) + { + this.capturePage(Entire, cFSSave, this.Key); + }, + + // Capture web page and *copy to clipboard* + copyPage : function(Entire) + { + this.capturePage(Entire, cFSClipboard, this.Key); + }, + + // Capture web page and *EMail* + emailPage : function(Entire) + { + this.capturePage(Entire, cFSEMail, this.Key); + }, + + // Capture web page and *open it in a third-party editor* + exportPage : function(Entire) + { + this.capturePage(Entire, cFSExternal, this.Key); + }, + + // Capture web page and *upload to free image hosting* + uploadPage : function(Entire) + { + this.capturePage(Entire, cFSUpload, this.Key); + }, + + // Capture web page and *print* + printPage : function(Entire) + { + this.capturePage(Entire, cFSPrint, this.Key); + }, + + // Check whether the addon is available and display the message if required + checkAvailability : function() + { + // The plugin works only in Windows OS. We check it here. + if (!this.isWindows() || !this.isFirefox()) + { + this.errorOnlyFirefoxAtWindows(); + return; + } + + if (!this.isAvailable() && confirm("FireShot plugin for Firefox not found. Would you like to install it?")) + this.installPlugin(); + }, + + // Check whether current OS is Windows + isWindows : function() + { + return navigator.appVersion.indexOf("Win") != -1; + }, + + // Check whether current browser is Firefox + isFirefox : function() + { + return navigator.userAgent.indexOf("Firefox") != -1; + }, + + // Displays error message + errorOnlyFirefoxAtWindows : function() + { + alert("Sorry, this plugin works only in Firefox under Windows OS."); + } + + + +} \ No newline at end of file -- You received this message because you are subscribed to the Google Groups "symfony SVN" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/symfony-svn?hl=en.
