Permalink
Browse files

Move editor php classes to dedicated namespace.

  • Loading branch information...
1 parent 7ec6edf commit eaa9c5080a56991dbecf493bd4fd31a540a3a120 @cdujeu cdujeu committed Jun 22, 2016
Showing with 268 additions and 63 deletions.
  1. +1 −1 core/src/plugins/action.share/src/ShareCenter.php
  2. +44 −0 core/src/plugins/core.access/src/Exception/FileNotFoundException.php
  3. +13 −9 core/src/plugins/editor.audio/{class.AudioPreviewer.php → AudioPreviewer.php}
  4. +1 −1 core/src/plugins/editor.audio/manifest.xml
  5. +12 −4 core/src/plugins/editor.browser/{class.FileMimeSender.php → FileMimeSender.php}
  6. +2 −2 core/src/plugins/editor.browser/manifest.xml
  7. +17 −5 core/src/plugins/editor.diaporama/{class.ImagePreviewer.php → ImagePreviewer.php}
  8. +1 −1 core/src/plugins/editor.diaporama/manifest.xml
  9. +54 −14 core/src/plugins/editor.eml/{class.EmlParser.php → EmlParser.php}
  10. +1 −1 core/src/plugins/editor.eml/manifest.xml
  11. +18 −4 core/src/plugins/editor.etherpad/{class.EtherpadClient.php → EtherpadClient.php}
  12. +1 −1 core/src/plugins/editor.etherpad/manifest.xml
  13. +48 −3 core/src/plugins/editor.imagick/{class.IMagickPreviewer.php → IMagickPreviewer.php}
  14. +1 −1 core/src/plugins/editor.imagick/manifest.xml
  15. +13 −3 core/src/plugins/editor.pixlr/{class.PixlrEditor.php → PixlrEditor.php}
  16. +1 −1 core/src/plugins/editor.pixlr/manifest.xml
  17. +1 −1 core/src/plugins/editor.soundmanager/manifest.xml
  18. +12 −4 core/src/plugins/editor.video/{class.VideoReader.php → VideoReader.php}
  19. +1 −1 core/src/plugins/editor.video/manifest.xml
  20. +25 −5 core/src/plugins/editor.zoho/{class.ZohoEditor.php → ZohoEditor.php}
  21. +1 −1 core/src/plugins/editor.zoho/manifest.xml
@@ -1131,7 +1131,7 @@ private function findMirrorNodesInShares($node, $direction){
if($node->getRepository()->hasParent()){
$parentRepoId = $node->getRepository()->getParentId();
$parentRepository = RepositoryService::getRepositoryById($parentRepoId);
- if(!empty($parentRepository) && !$parentRepository->isTemplate){
+ if(!empty($parentRepository) && !$parentRepository->isTemplate()){
$currentRoot = $node->getRepository()->getContextOption($crtContext, "PATH");
$newContext = $crtContext->withRepositoryId($parentRepoId);
$owner = $node->getRepository()->getOwner();
@@ -0,0 +1,44 @@
+<?php
+/*
+ * Copyright 2007-2016 Abstrium <contact (at) pydio.com>
+ * This file is part of Pydio.
+ *
+ * Pydio is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pydio 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.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Pydio. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The latest code can be found at <https://pydio.com/>.
+ */
+namespace Pydio\Access\Core\Exception;
+
+use Pydio\Core\Exception\PydioException;
+
+defined('AJXP_EXEC') or die('Access not allowed');
+
+/**
+ * Class FileNotFoundException
+ * @package Pydio\Access\Core\Exception
+ */
+class FileNotFoundException extends PydioException
+{
+ private $filePath;
+
+ /**
+ * FileNotFoundException constructor.
+ * @param string $filePath
+ */
+ public function __construct($filePath)
+ {
+ $this->filePath = $filePath;
+ parent::__construct("Cannot find file!", false, 5015);
+ }
+}
@@ -1,6 +1,6 @@
<?php
/*
- * Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
+ * Copyright 2007-2016 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
@@ -19,10 +19,13 @@
* The latest code can be found at <http://pyd.io/>.
*/
+namespace Pydio\Plugins\Editor;
+
use Pydio\Access\Core\AJXP_MetaStreamWrapper;
+use Pydio\Access\Core\Exception\FileNotFoundException;
use Pydio\Access\Core\Model\AJXP_Node;
use Pydio\Access\Core\Model\UserSelection;
-use Pydio\Core\Services\AuthService;
+use Pydio\Core\Http\Middleware\SecureTokenMiddleware;
use Pydio\Core\Controller\Controller;
use Pydio\Core\Utils\Utils;
@@ -32,9 +35,9 @@
defined('AJXP_EXEC') or die( 'Access not allowed');
/**
+ * Class AudioPreviewer
* Streams MP3 files to a client
- * @package AjaXplorer_Plugins
- * @subpackage Editor
+ * @package Pydio\Plugins\Editor
*/
class AudioPreviewer extends Plugin
{
@@ -43,7 +46,7 @@ class AudioPreviewer extends Plugin
* Action Controller
* @param \Psr\Http\Message\ServerRequestInterface $requestInterface
* @param \Psr\Http\Message\ResponseInterface $responseInterface
- * @throws Exception
+ * @throws FileNotFoundException
*/
public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface)
{
@@ -67,15 +70,15 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
if(!$exist && strpos($httpVars["file"], "base64encoded:") === false){
$file = Utils::decodeSecureMagic(base64_decode($httpVars["file"]));
if(!file_exists($destStreamURL.$file)){
- throw new Exception("Cannot find file!");
+ throw new FileNotFoundException($file);
}else{
$user = $node->getUserId();
$node = new AJXP_Node($destStreamURL.$file);
$node->setUserId($user);
}
}
if(!is_readable($node->getUrl())){
- throw new Exception("Cannot find file!");
+ throw new FileNotFoundException($node->getPath());
}
@@ -112,21 +115,22 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
// Transform the XML into XSPF
$xmlString = $responseInterface->getBody()->getContents();
$responseInterface->getBody()->rewind();
- $xmlDoc = new DOMDocument();
+ $xmlDoc = new \DOMDocument();
$xmlDoc->loadXML($xmlString);
$xElement = $xmlDoc->documentElement;
$xmlBuff = "";
header("Content-Type:application/xspf+xml;charset=UTF-8");
$xmlBuff.='<?xml version="1.0" encoding="UTF-8"?>';
$xmlBuff.='<playlist version="1" xmlns="http://xspf.org/ns/0/">';
$xmlBuff.="<trackList>";
+ /** @var \DOMElement $child */
foreach ($xElement->childNodes as $child) {
$isFile = ($child->getAttribute("is_file") == "true");
$label = $child->getAttribute("text");
$ar = explode(".", $label);
$ext = strtolower(end($ar));
if(!$isFile || $ext != "mp3") continue;
- $xmlBuff.="<track><location>".AJXP_SERVER_ACCESS."?secure_token=".AuthService::getSecureToken()."&get_action=audio_proxy&file=".base64_encode($child->getAttribute("filename"))."</location><title>".$label."</title></track>";
+ $xmlBuff.="<track><location>".AJXP_SERVER_ACCESS."?secure_token=".SecureTokenMiddleware::getSecureToken()."&get_action=audio_proxy&file=".base64_encode($child->getAttribute("filename"))."</location><title>".$label."</title></track>";
}
$xmlBuff.="</trackList>";
$xmlBuff.= "</playlist>";
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<editor id="editor.audio" order="1000" enabled="true" modalOnly="true" openable="false" previewProvider="true" text="186" title="136" icon="frame_image.png" className="AudioPreviewer" mimes="mp3" label="CONF_MESSAGE[Audio Player]" description="CONF_MESSAGE[Inserts a flash player for reading mp3 files online, and playing a whole folder in a separate window.]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
- <class_definition filename="plugins/editor.audio/class.AudioPreviewer.php" classname="AudioPreviewer"/>
+ <class_definition filename="plugins/editor.audio/AudioPreviewer.php" classname="Pydio\Plugins\Editor\AudioPreviewer"/>
<client_settings>
<resources>
<js file="plugins/editor.audio/class.AudioPreviewer.js" className="AudioPreviewer"/>
@@ -1,6 +1,6 @@
<?php
/*
- * Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
+ * Copyright 2007-2016 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
@@ -19,6 +19,8 @@
* The latest code can be found at <http://pyd.io/>.
*/
+namespace Pydio\Plugins\Editor;
+
use Pydio\Access\Core\AJXP_MetaStreamWrapper;
use Pydio\Access\Core\Model\UserSelection;
@@ -31,12 +33,18 @@
defined('AJXP_EXEC') or die( 'Access not allowed');
/**
+ * Class FileMimeSender
* Extract the mimetype of a file and send it to the browser
- * @package AjaXplorer_Plugins
- * @subpackage Editor
+ * @package Pydio\Plugins\Editor
*/
class FileMimeSender extends Plugin
{
+ /**
+ * @param \Psr\Http\Message\ServerRequestInterface $requestInterface
+ * @param \Psr\Http\Message\ResponseInterface $responseInterface
+ * @throws \Pydio\Core\Exception\AuthRequiredException
+ * @throws \Pydio\Core\Exception\PydioException
+ */
public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestInterface, \Psr\Http\Message\ResponseInterface &$responseInterface)
{
if($requestInterface->getAttribute("action") !== "open_file"){
@@ -71,7 +79,7 @@ public function switchAction(\Psr\Http\Message\ServerRequestInterface $requestIn
//Get mimetype with fileinfo PECL extension
if (class_exists("finfo")) {
- $finfo = new finfo(FILEINFO_MIME);
+ $finfo = new \finfo(FILEINFO_MIME);
$fileMime = $finfo->buffer(fread($fp, 2000));
}
//Get mimetype with (deprecated) mime_content_type
@@ -28,8 +28,8 @@
<!-- Stream Wrapper Access -->
<activePlugin pluginName="access.AJXP_STREAM_PROVIDER"/>
</dependencies>
- <class_definition filename="plugins/editor.browser/class.FileMimeSender.php"
- classname="FileMimeSender" />
+ <class_definition filename="plugins/editor.browser/FileMimeSender.php"
+ classname="Pydio\Plugins\Editor\FileMimeSender" />
<registry_contributions>
<actions>
<action name="open_file" skipSecureToken="true">
@@ -1,6 +1,6 @@
<?php
/*
- * Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
+ * Copyright 2007-2016 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
@@ -18,6 +18,7 @@
*
* The latest code can be found at <http://pyd.io/>.
*/
+namespace Pydio\Plugins\Editor;
use Pydio\Access\Core\AJXP_MetaStreamWrapper;
use Pydio\Access\Core\Model\AJXP_Node;
@@ -31,14 +32,21 @@
defined('AJXP_EXEC') or die( 'Access not allowed');
/**
+ * Class ImagePreviewer
* Generate an image thumbnail and send the thumb/full version to the browser
- * @package AjaXplorer_Plugins
- * @subpackage Editor
+ * @package Pydio\Plugins\Editor
*/
class ImagePreviewer extends Plugin
{
private $currentDimension;
+ /**
+ * @param $action
+ * @param $httpVars
+ * @param $filesVars
+ * @param \Pydio\Core\Model\ContextInterface $contextInterface
+ * @throws \Exception
+ */
public function switchAction($action, $httpVars, $filesVars, \Pydio\Core\Model\ContextInterface $contextInterface)
{
if (!isSet($this->pluginConf)) {
@@ -130,7 +138,7 @@ public function generateThumbnail(\Pydio\Core\Model\ContextInterface $ctx, $mast
{
$size = $this->currentDimension;
require_once(AJXP_INSTALL_PATH."/plugins/editor.diaporama/PThumb.lib.php");
- $pThumb = new PThumb($this->getContextualOption($ctx, "THUMBNAIL_QUALITY"), $this->getContextualOption($ctx, "EXIF_ROTATION"));
+ $pThumb = new \PThumb($this->getContextualOption($ctx, "THUMBNAIL_QUALITY"), $this->getContextualOption($ctx, "EXIF_ROTATION"));
if (!$pThumb->isError()) {
$pThumb->remote_wrapper = "Pydio\\Access\\Core\\AJXP_MetaStreamWrapper";
@@ -191,7 +199,7 @@ public function extractImageMetadata(&$ajxpNode)
if($this->getContextualOption($context, "EXIF_ROTATION")){
require_once(AJXP_INSTALL_PATH."/plugins/editor.diaporama/PThumb.lib.php");
- $pThumb = new PThumb($this->getContextualOption($context, "THUMBNAIL_QUALITY"),$this->getContextualOption($context, "EXIF_ROTATION"));
+ $pThumb = new \PThumb($this->getContextualOption($context, "THUMBNAIL_QUALITY"),$this->getContextualOption($context, "EXIF_ROTATION"));
$orientation = $pThumb->exiforientation($realFile, false);
if ($pThumb->rotationsupported($orientation))
{
@@ -214,6 +222,10 @@ public function extractImageMetadata(&$ajxpNode)
//$this->logDebug("CURRENT NODE IN EXTRACT IMAGE METADATA ", $ajxpNode);
}
+ /**
+ * @param $filename
+ * @return bool
+ */
protected function handleMime($filename)
{
$mimesAtt = explode(",", $this->getXPath()->query("@mimes")->item(0)->nodeValue);
@@ -8,7 +8,7 @@
<global_param name="THUMBNAIL_QUALITY" type="integer" label="CONF_MESSAGE[Quality]" description="CONF_MESSAGE[Thumbs quality]" default="2"/>
<global_param name="EXIF_ROTATION" type="boolean" label="CONF_MESSAGE[Exif Rotation]" description="CONF_MESSAGE[Rotate image using exif rotation]" default="true"/>
</server_settings>
- <class_definition filename="plugins/editor.diaporama/class.ImagePreviewer.php" classname="ImagePreviewer"/>
+ <class_definition filename="plugins/editor.diaporama/ImagePreviewer.php" classname="Pydio\Plugins\Editor\ImagePreviewer"/>
<client_settings>
<resources>
<js file="plugins/editor.diaporama/class.Diaporama.js" className="Diaporama"/>
Oops, something went wrong.

0 comments on commit eaa9c50

Please sign in to comment.