| 
									
										
										
										
											2013-06-30 20:53:42 +02:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2015-12-16 17:57:44 +03:00
										 |  |  |  * ownCloud - Richdocuments App | 
					
						
							| 
									
										
										
										
											2013-06-30 20:53:42 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @author Frank Karlitschek | 
					
						
							| 
									
										
										
										
											2014-04-09 19:04:33 +03:00
										 |  |  |  * @copyright 2013-2014 Frank Karlitschek karlitschek@kde.org | 
					
						
							| 
									
										
										
										
											2015-01-14 16:33:11 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-06-30 20:53:42 +02:00
										 |  |  |  * This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE | 
					
						
							| 
									
										
										
										
											2015-01-14 16:33:11 +01:00
										 |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							| 
									
										
										
										
											2013-06-30 20:53:42 +02:00
										 |  |  |  * version 3 of the License, or any later version. | 
					
						
							| 
									
										
										
										
											2015-01-14 16:33:11 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-06-30 20:53:42 +02:00
										 |  |  |  * This library 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 AFFERO GENERAL PUBLIC LICENSE for more details. | 
					
						
							| 
									
										
										
										
											2015-01-14 16:33:11 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2014-05-17 15:29:51 -04:00
										 |  |  |  * You should have received a copy of the GNU Affero General Public | 
					
						
							| 
									
										
										
										
											2013-06-30 20:53:42 +02:00
										 |  |  |  * License along with this library.  If not, see <http://www.gnu.org/licenses/>. | 
					
						
							| 
									
										
										
										
											2015-01-14 16:33:11 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2013-06-30 20:53:42 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-16 17:57:44 +03:00
										 |  |  | namespace OCA\Richdocuments\AppInfo; | 
					
						
							| 
									
										
										
										
											2015-06-16 19:32:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-07 18:46:52 +01:00
										 |  |  | use OC\Security\CSP\ContentSecurityPolicy; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-18 23:47:01 +02:00
										 |  |  | $eventDispatcher = \OC::$server->getEventDispatcher(); | 
					
						
							|  |  |  | $eventDispatcher->addListener( | 
					
						
							|  |  |  | 	'OCA\Files::loadAdditionalScripts', | 
					
						
							|  |  |  | 	function() { | 
					
						
							| 
									
										
										
										
											2015-12-16 17:57:44 +03:00
										 |  |  | 		\OCP\Util::addScript('richdocuments', 'viewer/viewer'); | 
					
						
							| 
									
										
										
										
											2016-06-15 22:36:14 +05:30
										 |  |  | 		\OCP\Util::addStyle('richdocuments', 'viewer/odfviewer'); | 
					
						
							| 
									
										
										
										
											2015-07-10 08:11:44 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-18 23:47:01 +02:00
										 |  |  | ); | 
					
						
							| 
									
										
										
										
											2016-12-07 00:57:01 +01:00
										 |  |  | $eventDispatcher->addListener( | 
					
						
							|  |  |  | 	'OCA\Files_Sharing::loadAdditionalScripts', | 
					
						
							|  |  |  | 	function() { | 
					
						
							|  |  |  | 		\OCP\Util::addScript('richdocuments', 'viewer/viewer'); | 
					
						
							|  |  |  | 		\OCP\Util::addStyle('richdocuments', 'viewer/odfviewer'); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | ); | 
					
						
							| 
									
										
										
										
											2013-10-20 21:51:03 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-13 12:28:54 +05:30
										 |  |  | if (class_exists('\OC\Files\Type\TemplateManager')) { | 
					
						
							|  |  |  |     $manager = \OC_Helper::getFileTemplateManager(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $manager->registerTemplate('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'apps/richdocuments/assets/docxtemplate.docx'); | 
					
						
							|  |  |  |     $manager->registerTemplate('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'apps/richdocuments/assets/xlsxtemplate.xlsx'); | 
					
						
							|  |  |  |     $manager->registerTemplate('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'apps/richdocuments/assets/pptxtemplate.pptx'); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-07 18:46:52 +01:00
										 |  |  | // Whitelist the wopi URL for iframes, required for Firefox
 | 
					
						
							|  |  |  | $wopiUrl = \OC::$server->getConfig()->getAppValue('richdocuments', 'wopi_url'); | 
					
						
							|  |  |  | if ($wopiUrl !== '') { | 
					
						
							|  |  |  | 	$manager = \OC::$server->getContentSecurityPolicyManager(); | 
					
						
							|  |  |  | 	$policy = new ContentSecurityPolicy(); | 
					
						
							|  |  |  | 	$policy->addAllowedFrameDomain($wopiUrl); | 
					
						
							|  |  |  | 	$manager->addDefaultPolicy($policy); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-06 12:53:09 +01:00
										 |  |  | // Listen to delete file signal
 | 
					
						
							| 
									
										
										
										
											2015-12-16 17:57:44 +03:00
										 |  |  | \OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Richdocuments\Storage", "onDelete"); |