| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-16 17:57:44 +03:00
										 |  |  | use OCA\Richdocuments\Filter\Office; | 
					
						
							|  |  |  | use OCA\Richdocuments\Config; | 
					
						
							| 
									
										
										
										
											2015-06-16 19:32:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | $app = new Application(); | 
					
						
							|  |  |  | $c = $app->getContainer(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-16 17:57:44 +03:00
										 |  |  | \OCP\App::registerAdmin('richdocuments', 'admin'); | 
					
						
							|  |  |  | \OCP\App::registerPersonal('richdocuments', 'personal'); | 
					
						
							| 
									
										
										
										
											2013-06-30 20:53:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-16 19:32:25 +03:00
										 |  |  | $navigationEntry = function () use ($c) { | 
					
						
							|  |  |  | 	return [ | 
					
						
							| 
									
										
										
										
											2015-12-16 17:57:44 +03:00
										 |  |  | 		'id' => 'richdocuments_index', | 
					
						
							| 
									
										
										
										
											2015-06-16 19:32:25 +03:00
										 |  |  | 		'order' => 2, | 
					
						
							| 
									
										
										
										
											2015-12-16 17:57:44 +03:00
										 |  |  | 		'href' => $c->query('ServerContainer')->getURLGenerator()->linkToRoute('richdocuments.document.index'), | 
					
						
							|  |  |  | 		'icon' => $c->query('ServerContainer')->getURLGenerator()->imagePath('richdocuments', 'documents.svg'), | 
					
						
							| 
									
										
										
										
											2015-12-06 11:45:52 +01:00
										 |  |  | 		'name' => $c->query('L10N')->t('Collabora Online Development Edition') | 
					
						
							| 
									
										
										
										
											2015-06-16 19:32:25 +03:00
										 |  |  | 	]; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | $c->getServer()->getNavigationManager()->add($navigationEntry); | 
					
						
							| 
									
										
										
										
											2013-07-01 21:48:49 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-20 21:51:03 +03:00
										 |  |  | //Script for registering file actions
 | 
					
						
							| 
									
										
										
										
											2015-07-10 08:11:44 +02:00
										 |  |  | $request = \OC::$server->getRequest(); | 
					
						
							|  |  |  | if (isset($request->server['REQUEST_URI'])) { | 
					
						
							|  |  |  | 	$url = $request->server['REQUEST_URI']; | 
					
						
							| 
									
										
										
										
											2015-01-14 16:33:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 08:11:44 +02:00
										 |  |  | 	if (preg_match('%index.php/apps/files(/.*)?%', $url)) { | 
					
						
							| 
									
										
										
										
											2015-12-16 17:57:44 +03:00
										 |  |  | 		\OCP\Util::addScript('richdocuments', 'viewer/viewer'); | 
					
						
							| 
									
										
										
										
											2015-07-10 08:11:44 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-01-14 16:33:11 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2013-10-20 21:51:03 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-18 22:10:27 +03:00
										 |  |  | if ($c->query('AppConfig')->isConverterEnabled()){ | 
					
						
							| 
									
										
										
										
											2015-10-29 15:07:44 -04:00
										 |  |  | 	$odtFilter = new Office( | 
					
						
							| 
									
										
										
										
											2015-06-16 19:32:25 +03:00
										 |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.oasis.opendocument.text', | 
					
						
							|  |  |  | 					'format' => 'odt:writer8', | 
					
						
							|  |  |  | 					'extension' => 'odt' | 
					
						
							|  |  |  | 				], | 
					
						
							| 
									
										
										
										
											2015-10-29 15:07:44 -04:00
										 |  |  | 			'write' => | 
					
						
							| 
									
										
										
										
											2015-06-16 19:32:25 +03:00
										 |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/msword', | 
					
						
							|  |  |  | 					'format' => 'doc', | 
					
						
							|  |  |  | 					'extension' => 'doc' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							| 
									
										
										
										
											2014-03-28 22:14:51 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-16 19:32:25 +03:00
										 |  |  | 	$docxFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.oasis.opendocument.text', | 
					
						
							|  |  |  | 					'format' => 'odt:writer8', | 
					
						
							|  |  |  | 					'extension' => 'odt' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', | 
					
						
							|  |  |  | 					'format' => 'docx', | 
					
						
							|  |  |  | 					'extension' => 'docx' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							| 
									
										
										
										
											2014-11-06 19:31:25 +03:00
										 |  |  | 	); | 
					
						
							| 
									
										
										
										
											2015-10-29 15:07:44 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	$odpFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.oasis.opendocument.presentation', | 
					
						
							|  |  |  | 					'format' => 'odp', | 
					
						
							|  |  |  | 					'extension' => 'odp' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.oasis.opendocument.presentation', | 
					
						
							|  |  |  | 					'format' => 'dop', | 
					
						
							|  |  |  | 					'extension' => 'odp' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$odsFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.oasis.opendocument.spreadsheet', | 
					
						
							|  |  |  | 					'format' => 'ods', | 
					
						
							|  |  |  | 					'extension' => 'ods' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.oasis.opendocument.spreadsheet', | 
					
						
							|  |  |  | 					'format' => 'ods', | 
					
						
							|  |  |  | 					'extension' => 'ods' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$odgFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.oasis.opendocument.graphics', | 
					
						
							|  |  |  | 					'format' => 'odg', | 
					
						
							|  |  |  | 					'extension' => 'odg' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.oasis.opendocument.graphics', | 
					
						
							|  |  |  | 					'format' => 'odg', | 
					
						
							|  |  |  | 					'extension' => 'odg' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$docFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/msword', | 
					
						
							|  |  |  | 					'format' => 'doc', | 
					
						
							|  |  |  | 					'extension' => 'doc' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/msword', | 
					
						
							|  |  |  | 					'format' => 'doc', | 
					
						
							|  |  |  | 					'extension' => 'doc' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$lwpFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.lotus-wordpro', | 
					
						
							|  |  |  | 					'format' => 'lwp', | 
					
						
							|  |  |  | 					'extension' => 'lwp' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.lotus-wordpro', | 
					
						
							|  |  |  | 					'format' => 'lwp', | 
					
						
							|  |  |  | 					'extension' => 'lwp' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$svgFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'image/svg+xml', | 
					
						
							|  |  |  | 					'format' => 'svg', | 
					
						
							|  |  |  | 					'extension' => 'svg' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'image/svg+xml', | 
					
						
							|  |  |  | 					'format' => 'svg', | 
					
						
							|  |  |  | 					'extension' => 'svg' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$potFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.ms-powerpoint', | 
					
						
							|  |  |  | 					'format' => 'pot', | 
					
						
							|  |  |  | 					'extension' => 'pot' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.ms-powerpoint', | 
					
						
							|  |  |  | 					'format' => 'pot', | 
					
						
							|  |  |  | 					'extension' => 'pot' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$xlaFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.ms-excel', | 
					
						
							|  |  |  | 					'format' => 'xla', | 
					
						
							|  |  |  | 					'extension' => 'xla' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.ms-excel', | 
					
						
							|  |  |  | 					'format' => 'xla', | 
					
						
							|  |  |  | 					'extension' => 'xla' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$xlaFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.ms-excel', | 
					
						
							|  |  |  | 					'format' => 'xla', | 
					
						
							|  |  |  | 					'extension' => 'xla' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.ms-excel', | 
					
						
							|  |  |  | 					'format' => 'xla', | 
					
						
							|  |  |  | 					'extension' => 'xla' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$xlsxFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', | 
					
						
							|  |  |  | 					'format' => 'xlsx', | 
					
						
							|  |  |  | 					'extension' => 'xlsx' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', | 
					
						
							|  |  |  | 					'format' => 'xlsx', | 
					
						
							|  |  |  | 					'extension' => 'xlsx' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$vsdFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.visio', | 
					
						
							|  |  |  | 					'format' => 'vsd', | 
					
						
							|  |  |  | 					'extension' => 'vsd' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.visio', | 
					
						
							|  |  |  | 					'format' => 'vsd', | 
					
						
							|  |  |  | 					'extension' => 'vsd' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$wpdFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.wordperfect', | 
					
						
							|  |  |  | 					'format' => 'wpd', | 
					
						
							|  |  |  | 					'extension' => 'wpd' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.wordperfect', | 
					
						
							|  |  |  | 					'format' => 'wpd', | 
					
						
							|  |  |  | 					'extension' => 'wpd' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$wpdFilter = new Office( | 
					
						
							|  |  |  | 		[ | 
					
						
							|  |  |  | 			'read' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.wordperfect', | 
					
						
							|  |  |  | 					'format' => 'wpd', | 
					
						
							|  |  |  | 					'extension' => 'wpd' | 
					
						
							|  |  |  | 				], | 
					
						
							|  |  |  | 			'write' => | 
					
						
							|  |  |  | 				[ | 
					
						
							|  |  |  | 					'target' => 'application/vnd.wordperfect', | 
					
						
							|  |  |  | 					'format' => 'wpd', | 
					
						
							|  |  |  | 					'extension' => 'wpd' | 
					
						
							|  |  |  | 				] | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	); | 
					
						
							| 
									
										
										
										
											2014-11-06 19:31:25 +03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-03-28 22:14:51 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-07 21:26:22 +03:00
										 |  |  | //Listen to delete file signal
 | 
					
						
							| 
									
										
										
										
											2015-12-16 17:57:44 +03:00
										 |  |  | \OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Richdocuments\Storage", "onDelete"); |