Alex Trofimov hace 9 años
padre
commit
91cafc287f
Se han modificado 34 ficheros con 784 adiciones y 17 borrados
  1. 124 0
      inc/classes/BxDolFileHandler.php
  2. 37 0
      inc/classes/BxDolFileHandlerQuery.php
  3. 34 3
      inc/classes/BxDolStorage.php
  4. 0 0
      install/sql/system.sql
  5. 11 2
      modules/base/text/classes/BxBaseModTextTemplate.php
  6. 5 1
      modules/boonex/english/data/langs/system/en.xml
  7. 23 0
      modules/boonex/files/classes/BxFilesModule.php
  8. 52 3
      modules/boonex/files/classes/BxFilesTemplate.php
  9. 11 0
      modules/boonex/files/classes/BxFilesUploaderHTML5.php
  10. 11 0
      modules/boonex/files/classes/BxFilesUploaderSimple.php
  11. 1 0
      modules/boonex/files/install/langs/en.xml
  12. 2 2
      modules/boonex/files/install/sql/enable.sql
  13. 30 0
      modules/boonex/files/template/css/main.css
  14. 19 3
      modules/boonex/files/template/unit.html
  15. 28 1
      modules/boonex/files/template/unit_gallery.html
  16. 21 0
      modules/boonex/ocean/data/template/system/scripts/BxTemplFileHandlerCodeViewer.php
  17. 21 0
      modules/boonex/ocean/data/template/system/scripts/BxTemplFileHandlerGoogleViewer.php
  18. 21 0
      modules/boonex/ocean/data/template/system/scripts/BxTemplFileHandlerImagesViewer.php
  19. 21 0
      modules/boonex/ocean/data/template/system/scripts/BxTemplFileHandlerMsViewer.php
  20. 21 0
      modules/boonex/protean/data/template/system/scripts/BxTemplFileHandlerCodeViewer.php
  21. 21 0
      modules/boonex/protean/data/template/system/scripts/BxTemplFileHandlerGoogleViewer.php
  22. 21 0
      modules/boonex/protean/data/template/system/scripts/BxTemplFileHandlerImagesViewer.php
  23. 21 0
      modules/boonex/protean/data/template/system/scripts/BxTemplFileHandlerMsViewer.php
  24. 5 1
      modules/boonex/russian/data/langs/system/ru.xml
  25. 24 1
      samples/storage.php
  26. 14 0
      template/css/file_handler.css
  27. 10 0
      template/file_handler_code.html
  28. 1 0
      template/file_handler_iframe.html
  29. 1 0
      template/file_handler_img.html
  30. 38 0
      template/scripts/BxBaseFileHandler.php
  31. 43 0
      template/scripts/BxBaseFileHandlerCodeViewer.php
  32. 31 0
      template/scripts/BxBaseFileHandlerGoogleViewer.php
  33. 30 0
      template/scripts/BxBaseFileHandlerImagesViewer.php
  34. 31 0
      template/scripts/BxBaseFileHandlerMsViewer.php

+ 124 - 0
inc/classes/BxDolFileHandler.php

@@ -0,0 +1,124 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+/**
+ * @page objects
+ * @section file_handler File view handlers
+ * @ref BxDolFileHandler
+ */
+
+/**
+ * File preview object, it's used to preview different files in browser which browse usually doesn't support.
+ * 
+ *
+ * @section file_handler_add Adding new files handler:
+ *
+ *
+ * Add record to 'sys_objects_file_handlers' table:
+ *
+ * - object: name of the file handler object, in the format: vendor prefix, underscore, module prefix, underscore, internal identifier or nothing; for example: bx_abode_pdf - custom file handler from Abode to display PDF files in browser.
+ * - title: file handler title
+ * - override_class_name: user defined class name which is derived from one of base file handler class.
+ * - override_class_file: the location of the user defined class, leave it empty if class is located in system folders.
+ *
+ *
+ * @section example Example of usage
+ *
+ * Display file preview:
+ *
+ * @code
+ *  $oFileHandler = BxDolFileHandler::getObjectInstanceByFile('hello.pdf'); // get file preview class
+ *  if ($oFileHandler) // check if preview is available for gived file
+ *      echo $oFileHandler->display (); // output HTML which will automatically show file preview
+ * @endcode
+ *
+ */
+class BxDolFileHandler extends BxDolFactory implements iBxDolFactoryObject
+{
+    protected $_sObject;
+    protected $_aObject;
+
+    /**
+     * Constructor
+     * @param $aObject array of file handler options
+     */
+    protected function __construct($aObject)
+    {
+        parent::__construct();
+
+        $this->_sObject = $aObject['object'];
+        $this->_aObject = $aObject;
+    }
+
+    /**
+     * Get file handler object instance by object name
+     * @param $sObject object name
+     * @return object instance or false on error
+     */
+    static public function getObjectInstance($sObject)
+    {
+        if (isset($GLOBALS['bxDolClasses'][__CLASS__.'!'.$sObject]))
+            return $GLOBALS['bxDolClasses'][__CLASS__.'!'.$sObject];
+
+        $aObjects = BxDolFileHandlerQuery::getObjects();
+        if (!$aObjects || !isset($aObjects[$sObject]))
+            return false;
+
+        $aObject = $aObjects[$sObject];
+
+        if (empty($aObject['override_class_name']))
+            return false;
+
+        $sClass = $aObject['override_class_name'];
+        if (!empty($aObject['override_class_file']))
+            require_once(BX_DIRECTORY_PATH_ROOT . $aObject['override_class_file']);
+
+        $o = new $sClass($aObject);
+        if (!$o->isActive())
+            return false;
+
+        return ($GLOBALS['bxDolClasses'][__CLASS__.'!'.$sObject] = $o);
+    }
+
+    /**
+     * Get file handler object instance by file name
+     * @param $sObject object name
+     * @return object instance or false on error
+     */
+    static public function getObjectInstanceByFile($sFileName)
+    {
+        if (!($aObjects = BxDolFileHandlerQuery::getObjects()))
+            return false;
+
+        $sObject = false;
+        foreach ($aObjects as $sObject => $aObject)
+            if (preg_match($aObject['preg_ext'], $sFileName))
+                return self::getObjectInstance($sObject);
+
+        return false;
+    }
+    
+    /**
+     * Display file preview
+     */
+    public function display ($sFileUrl, $aFile)
+    {
+        // override this function in particular class
+    }
+
+    /**
+     * Check if file preview is available
+     */
+    public function isActive ()
+    {
+        return $this->_aObject['active'];
+    }
+}
+
+/** @} */

+ 37 - 0
inc/classes/BxDolFileHandlerQuery.php

@@ -0,0 +1,37 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+/**
+ * Database queries for file handlers objects.
+ * @see BxDolFileHandler
+ */
+class BxDolFileHandlerQuery extends BxDolDb
+{
+    protected $_aObject;
+
+    public function __construct($aObject)
+    {
+        parent::__construct();
+        $this->_aObject = $aObject;
+    }
+
+    static public function getObjects ()
+    {
+        $oDb = BxDolDb::getInstance();
+        $sQuery = $oDb->prepare("SELECT * FROM `sys_objects_file_handlers` ORDER BY `order` ASC");
+        $aObjects = $oDb->getAllWithKey($sQuery, 'object');
+        if (!$aObjects || !is_array($aObjects))
+            return false;
+
+        return $aObjects;
+    }
+
+}
+
+/** @} */

+ 34 - 3
inc/classes/BxDolStorage.php

@@ -814,13 +814,44 @@ abstract class BxDolStorage extends BxDolFactory implements iBxDolFactoryObject
     {
         $sResult = '';
 
+        /* 
+         * These mime types must be manually added/replaced if they aren't defined in the mime type file
+         *
+
+            text/x-php                  php
+            text/x-coffeescript         coffee
+            text/x-common-lisp          lsp lisp
+            text/x-diff                 diff
+            text/x-go                   go
+            text/x-java                 java
+            text/x-lua                  lua
+            text/x-perl                 pl prl perl
+            text/x-python               py
+            text/nginx                  nginx
+            text/x-ini                  ini
+            text/x-ruby                 rb
+            text/x-sass                 sass
+            text/x-sh                   bash sh
+            text/x-swift                swift
+            text/x-vb                   vb
+            text/vbscript               vbs
+            text/x-vue                  vue
+            text/x-yaml                 yaml
+            text/x-sql                  sql
+            application/xquery          xq xquery
+            application/x-powershell    ps1
+            application/x-aspx          aps
+            application/x-jsp           jsp
+
+        */
+
         $aIconsFont = array (
             'file-pdf-o' => array('pdf'),
             'file-word-o' => array('doc', 'docx'),
             'file-excel-o' => array('xls', 'xlt', 'xlsx', 'sxc', 'stc', 'ods', 'ots', 'sdc', 'csv', 'dif', 'slk', 'pxl'),
             'file-powerpoint-o' => array('ppt', 'pptx', 'sxi', 'sti', 'odp', 'sdp', 'sdd'),
-            'file-code-o' => array('1st', 'aspx', 'asp', 'json', 'js', 'jsp', 'java', 'php', 'xml', 'rdf', 'xsd', 'xsl', 'xslt', 'sax', 'rss', 'cfm', 'js', 'asm', 'pl', 'prl', 'bas', 'b', 'vbs', 'fs', 'src', 'cs', 'ws', 'cgi', 'bat', 'py', 'c', 'cpp', 'cc', 'cp', 'h', 'hh', 'cxx', 'hxx', 'c++', 'm', 'lua', 'swift', 'sh', 'as', 'cob', 'tpl', 'lsp', 'x', 'cmd', 'rb', 'cbl', 'pas', 'pp', 'vb', 'f', 'perl', 'jl', 'lol', 'bal', 'pli', 'css', 'less', 'sass', 'saas', 'bcc', 'coffee', 'jade', 'j', 'tea', 'c#', 'sas', 'diff', 'pro', 'for', 'sh', 'bsh', 'bash', 'twig', 'csh', 'lisp', 'lsp', 'cobol', 'pl', 'd', 'git', 'rb', 'hrl', 'cr', 'inp', 'a', 'go', 'as3', 'm', 'sql'),
-            'file-image-o' => 'image/',
+            'file-code-o' => array('1st', 'aspx', 'asp', 'json', 'js', 'jsp', 'java', 'php', 'xml', 'html', 'xhtml', 'htm', 'rdf', 'xsd', 'xsl', 'xslt', 'sax', 'rss', 'dtd', 'cfm', 'js', 'asm', 'pl', 'prl', 'bas', 'b', 'fs', 'src', 'cs', 'ws', 'cgi', 'bat', 'py', 'c', 'cpp', 'cc', 'cp', 'h', 'hh', 'cxx', 'hxx', 'c++', 'm', 'lua', 'swift', 'sh', 'as', 'cob', 'tpl', 'lsp', 'x', 'cmd', 'rb', 'cbl', 'pas', 'pp', 'vb', 'vbs', 'f', 'perl', 'jl', 'lol', 'bal', 'pli', 'css', 'less', 'sass', 'saas', 'scss', 'bcc', 'coffee', 'jade', 'j', 'tea', 'c#', 'sas', 'diff', 'pro', 'for', 'sh', 'bsh', 'bash', 'twig', 'csh', 'lisp', 'lsp', 'cobol', 'pl', 'd', 'git', 'rb', 'hrl', 'cr', 'inp', 'a', 'go', 'as3', 'm', 'sql', 'md', 'mbox', 'nginx', 'pgp', 'asc', 'sig', 'ps1', 'rq', 'ttl', 'vue', 'xquery', 'xq'),
+            'file-image-o' => 'image/', 
             'file-video-o' => 'video/',
             'file-audio-o' => 'audio/',
             'file-text-o' => 'text/',
@@ -836,7 +867,7 @@ abstract class BxDolStorage extends BxDolFactory implements iBxDolFactoryObject
             'mime-type-presentation.png' => array('ppt', 'pptx', 'sxi', 'sti', 'odp', 'sdp', 'sdd'),
             'mime-type-spreadsheet.png' => array('xls', 'xlt', 'xlsx', 'sxc', 'stc', 'ods', 'ots', 'sdc', 'csv', 'dif', 'slk', 'pxl'),
             'mime-type-document.png' => array('doc', 'docx', 'odt', 'ott', 'sxw', 'stw', 'rtf', 'sdw', 'txt', 'pdb', 'psw', 'pdf'),
-            'mime-type-vector.png' => array('ac5', 'ac6', 'aff', 'agd1', 'ai', 'ait', 'art', 'awg', 'b2f', 'cag', 'cbd', 'cdl', 'cdr', 'cdr3', 'cdr4', 'cdr5', 'cdr6', 'cdrw', 'cdx', 'cgm', 'cht', 'cil', 'cit', 'cnv', 'csl', 'ctn', 'cv5', 'cvg', 'cvi', 'cvl', 'cvs', 'cvx', 'dcs', 'ddoc', 'ddrw', 'ded', 'design', 'dmw', 'do', 'dpp', 'dpr', 'draw', 'drw', 'dsf', 'dsf', 'dsx', 'dvg', 'dxb', 'emb', 'evf', 'fcd', 'fh', 'fhd', 'fmv', 'fs', 'ft10', 'ft11', 'ft9', 'ft8', 'gem', 'gl2', 'graffle', 'gsd', 'gsd', 'hpg', 'hpgl', 'hpgl2', 'hpl', 'hplj', 'hpp', 'hppcl', 'idw', 'ima', 'macdraw', 'md', 'mgcb', 'mgs', 'mvg', 'nap', 'naplps', 'odg', 'p10', 'pat', 'pct', 'pd', 'pdw', 'pgs', 'pic', 'pif', 'pix', 'plo', 'plot', 'plt', 'ps', 'psid', 'pws', 'rdl', 's57', 'sdw', 'sif', 'sk2', 'slddwg', 'sp', 'spa', 'svf', 'svg', 'svgb', 'svgz', 'sxd', 'tdr', 'tlc', 'tng', 'vbr', 'vec', 'vect', 'veh', 'vml', 'vss', 'web', 'web', 'web', 'yal'),
+            'mime-type-vector.png' => array('ac5', 'ac6', 'aff', 'agd1', 'ai', 'ait', 'art', 'awg', 'b2f', 'cag', 'cbd', 'cdl', 'cdr', 'cdr3', 'cdr4', 'cdr5', 'cdr6', 'cdrw', 'cdx', 'cgm', 'cht', 'cil', 'cit', 'cnv', 'csl', 'ctn', 'cv5', 'cvg', 'cvi', 'cvl', 'cvs', 'cvx', 'dcs', 'ddoc', 'ddrw', 'ded', 'design', 'dmw', 'do', 'dpp', 'dpr', 'draw', 'drw', 'dsf', 'dsf', 'dsx', 'dvg', 'dxb', 'emb', 'evf', 'fcd', 'fh', 'fhd', 'fmv', 'fs', 'ft10', 'ft11', 'ft9', 'ft8', 'gem', 'gl2', 'graffle', 'gsd', 'gsd', 'hpg', 'hpgl', 'hpgl2', 'hpl', 'hplj', 'hpp', 'hppcl', 'idw', 'ima', 'macdraw', 'mgcb', 'mgs', 'mvg', 'nap', 'naplps', 'odg', 'p10', 'pat', 'pct', 'pd', 'pdw', 'pgs', 'pic', 'pif', 'pix', 'plo', 'plot', 'plt', 'ps', 'psid', 'pws', 'rdl', 's57', 'sdw', 'sif', 'sk2', 'slddwg', 'sp', 'spa', 'svf', 'svg', 'svgb', 'svgz', 'sxd', 'tdr', 'tlc', 'tng', 'vbr', 'vec', 'vect', 'veh', 'vml', 'vss', 'web', 'web', 'web', 'yal'),
             'mime-type-archive.png' => array('7z', '7zip', 'aar', 'ace', 'alz', 'arj', 'bz2', 'bza', 'bzip2', 'bzp', 'bzp2', 'cab', 'czip', 'gnutar', 'gz', 'gza', 'gzi', 'gzip', 'ha', 'lhz', 'lzma', 'pzip', 'rar', 'roo', 's7z', 'tar', 'tar-gz', 'tar-lzma', 'tar-z', 'taz', 'tbz', 'tbz2', 'tgz', 'tz', 'z', 'zip', 'zipx', 'zix', 'zoo'),
         );
 

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
install/sql/system.sql


+ 11 - 2
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -113,11 +113,10 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         return '';
     }
 
-	protected function getUnit ($aData, $aParams = array())
+    protected function getUnitThumbAndGallery ($aData)
     {
         $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
 
-        // get thumb url
         $sPhotoThumb = '';
         $sPhotoGallery = '';
         if(!empty($CNF['FIELD_THUMB']) && $aData[$CNF['FIELD_THUMB']]) {
@@ -133,6 +132,16 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
                 $sPhotoGallery = $sPhotoThumb;
         }
 
+        return array($sPhotoThumb, $sPhotoGallery);
+    }
+
+	protected function getUnit ($aData, $aParams = array())
+    {
+        $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
+
+        // get thumb url
+        list($sPhotoThumb, $sPhotoGallery) = $this->getUnitThumbAndGallery($aData);
+
         // get entry url
         $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]);
 

+ 5 - 1
modules/boonex/english/data/langs/system/en.xml

@@ -1738,7 +1738,11 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_et_txt_subject_upgrade_success"><![CDATA[{site_name} upgrade success]]></string>
 	<string name="_sys_et_txt_subject_upgrade_modules_success"><![CDATA[Modules upgrade success on {site_name}]]></string>
 	<string name="_sys_et_txt_subject_bg_operation_failed"><![CDATA[Background operation failed]]></string>
-	<string name="_sys_et_txt_unsubscribe"><![CDATA[Unsubscribe]]></string>
+    <string name="_sys_et_txt_unsubscribe"><![CDATA[Unsubscribe]]></string>
+	<string name="_sys_file_handlers_ms_viewer"><![CDATA[Microsoft Office Viewer]]></string>
+	<string name="_sys_file_handlers_google_viewer"><![CDATA[Google Viewer]]></string>
+	<string name="_sys_file_handlers_images_viewer"><![CDATA[Images Viewer]]></string>
+	<string name="_sys_file_handlers_code_viewer"><![CDATA[Code Viewer]]></string>
 	<string name="_sys_form_account"><![CDATA[Account]]></string>
 	<string name="_sys_form_account_input_agreement"><![CDATA[]]></string>
 	<string name="_sys_form_account_input_agreement_value"><![CDATA[<div class="bx-def-font-small bx-def-font-grayed">By signing up, you agree to the <a href="{0}">Terms of Service</a> and <a href="{1}">Privacy Policy</a>.</div>]]></string>

+ 23 - 0
modules/boonex/files/classes/BxFilesModule.php

@@ -23,6 +23,29 @@ class BxFilesModule extends BxBaseModTextModule
     {
         return _t('_sys_txt_access_denied');
     }
+
+    public function getContentFile($aData) 
+    {
+        $CNF = $this->_oConfig->CNF;
+
+        if (!isset($aData[$CNF['FIELD_AUTHOR']]) || !isset($aData[$CNF['FIELD_ID']]))
+            return false;
+
+        $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
+        if (!$oStorage)
+            return false;
+
+        $aGhostFiles = $oStorage->getGhosts ($aData[$CNF['FIELD_AUTHOR']], $aData[$CNF['FIELD_ID']]);
+        if (!$aGhostFiles)
+            return false;
+
+        return array_pop($aGhostFiles);
+    }
+
+    public function serviceEntityFilePreview($iContentId = 0)
+    {
+        return $this->_serviceTemplateFunc ('entryFilePreview', $iContentId);
+    }
 }
 
 /** @} */

+ 52 - 3
modules/boonex/files/classes/BxFilesTemplate.php

@@ -14,14 +14,63 @@
  */
 class BxFilesTemplate extends BxBaseModTextTemplate
 {
-    /**
-     * Constructor
-     */
     function __construct(&$oConfig, &$oDb)
     {
         $this->MODULE = 'bx_files';
         parent::__construct($oConfig, $oDb);
     }
+
+    protected function getUnitThumbAndGallery ($aData)
+    {
+        $aFile = BxDolModule::getInstance($this->MODULE)->getContentFile($aData);
+
+        if (!in_array($aFile['ext'], array('jpg', 'jpeg', 'png', 'gif', /* when ImageMagick is used - 'tif', 'tiff', 'bmp', 'ico', 'psd' */)))
+            return array('', '');
+
+        $sPhotoThumb = '';
+        if ($oImagesTranscoder = BxDolTranscoderImage::getObjectInstance(BxDolModule::getInstance($this->MODULE)->_oConfig->CNF['OBJECT_IMAGES_TRANSCODER_GALLERY']))
+            $sPhotoThumb = $oImagesTranscoder->getFileUrl($aFile['id']);
+
+        return array($sPhotoThumb, $sPhotoThumb);
+    }
+    
+    function unit ($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html', $aParams = array())
+    {
+    	$sResult = $this->checkPrivacy ($aData, $isCheckPrivateContent, $this->getModule());
+    	if($sResult)
+            return $sResult;
+
+        $CNF = &BxDolModule::getInstance($this->MODULE)->_oConfig->CNF;
+
+        $aVars = $this->getUnit($aData, $aParams);
+
+        $aFile = BxDolModule::getInstance($this->MODULE)->getContentFile($aData);
+        
+        $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
+
+        $aVars['icon'] = $oStorage ? $oStorage->getFontIconNameByFileName($aFile['file_name']) : 'file-o';
+        if ($sTemplateName == 'unit_gallery.html') 
+            $aVars['bx_if:no_thumb']['content']['icon'] = $aVars['icon'];
+
+		return $this->parseHtmlByName($sTemplateName, $aVars);
+    }
+
+    function entryFilePreview ($aData)
+    {
+        $oModule = BxDolModule::getInstance($this->MODULE);
+        $CNF = $oModule->_oConfig->CNF;
+
+        if (!($aFile = $oModule->getContentFile($aData)))
+            return '';
+        if (!($oFileHandler = BxDolFileHandler::getObjectInstanceByFile($aFile['file_name'])))
+            return '';
+        if (!($oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE'])))
+            return '';
+        if (!($sFileUrl = $oStorage->getFileUrlById($aFile['id'])))
+            return '';
+
+        return $oFileHandler->display($sFileUrl, $aFile);
+    }
 }
 
 /** @} */

+ 11 - 0
modules/boonex/files/classes/BxFilesUploaderHTML5.php

@@ -28,6 +28,17 @@ class BxFilesUploaderHTML5 extends BxTemplUploaderHTML5
         $a['file_title_attr'] = bx_html_attribute($a['file_title']);
         return $a;
     }
+
+    protected function isUseTranscoderForPreview($oImagesTranscoder, $aFile)
+    {
+        if (!$oImagesTranscoder)
+            return false;
+
+        if (in_array($aFile['ext'], array('jpg', 'jpeg', 'png', 'gif', /* when ImageMagick is used - 'tif', 'tiff', 'bmp', 'ico', 'psd' */)) && (is_a($oImagesTranscoder, 'BxDolTranscoderImage') || is_a($oImagesTranscoder, 'BxDolTranscoderProxy')))
+            return true;
+        
+        return false;
+    }
 }
 
 /** @} */

+ 11 - 0
modules/boonex/files/classes/BxFilesUploaderSimple.php

@@ -28,6 +28,17 @@ class BxFilesUploaderSimple extends BxTemplUploaderSimple
         $a['file_title_attr'] = bx_html_attribute($a['file_title']);
         return $a;
     }
+
+    protected function isUseTranscoderForPreview($oImagesTranscoder, $aFile)
+    {
+        if (!$oImagesTranscoder)
+            return false;
+
+        if (in_array($aFile['ext'], array('jpg', 'jpeg', 'png', 'gif', /* when ImageMagick is used - 'tif', 'tiff', 'bmp', 'ico', 'psd' */)) && (is_a($oImagesTranscoder, 'BxDolTranscoderImage') || is_a($oImagesTranscoder, 'BxDolTranscoderProxy')))
+            return true;
+        
+        return false;
+    }
 }
 
 /** @} */

+ 1 - 0
modules/boonex/files/install/langs/en.xml

@@ -106,6 +106,7 @@
 	<string name="_bx_files_page_block_title_cats"><![CDATA[Files Categories]]></string>
 	<string name="_bx_files_page_block_title_entry_info"><![CDATA[Info]]></string>
 	<string name="_bx_files_page_block_title_my_entries"><![CDATA[My Files]]></string>
+	<string name="_bx_files_page_block_title_entry_file_preview"><![CDATA[File Preview]]></string>
 
     <string name="_bx_files_menu_set_title_view_entry"><![CDATA[File Actions]]></string>
     <string name="_bx_files_menu_title_view_entry"><![CDATA[File Actions]]></string>

+ 2 - 2
modules/boonex/files/install/sql/enable.sql

@@ -50,14 +50,14 @@ INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `lay
 ('bx_files_view_entry', '_bx_files_page_title_sys_view_entry', '_bx_files_page_title_view_entry', 'bx_files', 10, 2147483647, 1, 'view-file', '', '', '', '', 0, 1, 0, 'BxFilesPageEntry', 'modules/boonex/files/classes/BxFilesPageEntry.php');
 
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
-('bx_files_view_entry', 1, 'bx_files', '', '_bx_files_page_block_title_entry_text', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:17:\"entity_text_block\";}', 0, 0, 1, 0),
+('bx_files_view_entry', 1, 'bx_files', '', '_bx_files_page_block_title_entry_text', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:17:\"entity_text_block\";}', 0, 0, 1, 1),
+('bx_files_view_entry', 1, 'bx_files', '', '_bx_files_page_block_title_entry_file_preview', 3, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:19:\"entity_file_preview\";}', 0, 0, 1, 2),
 ('bx_files_view_entry', 2, 'bx_files', '', '_bx_files_page_block_title_entry_author', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:13:\"entity_author\";}', 0, 0, 1, 0),
 ('bx_files_view_entry', 3, 'bx_files', '', '_bx_files_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:11:\"entity_info\";}', 0, 0, 1, 1),
 ('bx_files_view_entry', 3, 'bx_files', '', '_bx_files_page_block_title_entry_location', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:15:\"entity_location\";}', 0, 0, 0, 2),
 ('bx_files_view_entry', 4, 'bx_files', '', '_bx_files_page_block_title_entry_all_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:18:\"entity_all_actions\";}', 0, 0, 1, 0),
 ('bx_files_view_entry', 4, 'bx_files', '', '_bx_files_page_block_title_entry_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:14:\"entity_actions\";}', 0, 0, 0, 1),
 ('bx_files_view_entry', 4, 'bx_files', '', '_bx_files_page_block_title_entry_social_sharing', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:21:\"entity_social_sharing\";}', 0, 0, 0, 2),
-('bx_files_view_entry', 4, 'bx_files', '', '_bx_files_page_block_title_entry_attachments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:18:\"entity_attachments\";}', 0, 0, 0, 3),
 ('bx_files_view_entry', 4, 'bx_files', '', '_bx_files_page_block_title_entry_comments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_files\";s:6:\"method\";s:15:\"entity_comments\";}', 0, 0, 1, 4),
 ('bx_files_view_entry', 4, 'bx_files', '', '_bx_files_page_block_title_entry_location', 3, 2147483647, 'service', 'a:4:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:13:\"locations_map\";s:6:\"params\";a:2:{i:0;s:8:\"bx_files\";i:1;s:4:\"{id}\";}s:5:\"class\";s:20:\"TemplServiceMetatags\";}', 0, 0, 1, 5);
 

+ 30 - 0
modules/boonex/files/template/css/main.css

@@ -4,3 +4,33 @@
 .bx_files_cover .bx-cover-title {
     margin-top:9rem;
 }
+
+.bx-files-text-unit-gallery .bx-base-text-unit-no-thumb {
+    position:relative;
+}
+
+.bx-files-text-unit-gallery .bx-base-text-unit-no-thumb .sys-icon {
+    left:0;
+    top:0;
+    width:100%;
+    position:absolute;
+    font-size:8rem; 
+    line-height:11.25rem;
+    overflow:hidden;
+}
+
+.bx-files-text-unit .bx-base-text-unit-text {
+    position:relative;
+}
+
+.bx-files-text-unit .bx-base-text-unit-text .sys-icon {
+    position:absolute;
+    top:0;
+    left:0;
+    font-size:3.2rem;
+}
+
+.bx-files-text-unit .bx-base-text-unit-text div,
+.bx-files-text-unit .bx-base-text-unit-text h2 {
+    margin-left:3.5rem;
+}

+ 19 - 3
modules/boonex/files/template/unit.html

@@ -1,3 +1,19 @@
-
-<bx_include_base:../modules/base/text/template/unit.html />
-
+<div class="bx-files-text-unit bx-base-text-unit bx-base-text-unit-ext bx-def-box bx-def-round-corners bx-def-color-bg-box bx-def-margin-bottom">
+	<bx_if:thumb>
+		<div class="bx-base-text-unit-cover">
+			<img class="bx-base-text-unit-cover bx-def-round-corners" alt="__title__" src="__thumb_url__" />
+		</div>
+	</bx_if:thumb>
+	<div class="bx-base-text-unit-text bx-def-padding bx-def-box-sizing">
+        <i class="sys-icon __icon__ bx-def-padding"></i>
+	    <h2><a href="__content_url__">__title__</a></h2>
+	    <div class="bx-base-text-unit-info bx-def-margin-sec-top bx-def-font-small">
+	        <span class="bx-def-font-grayed">__entry_posting_date__</span>
+	        <span class="bx-base-text-unit-info-div bx-def-font-grayed">&#183;</span>
+	        <a class="bx-base-text-unit-author" href="__author_url__">__author__</a>
+	    </div>
+	    <div class="bx-base-text-unit-summary bx-def-margin-sec-top bx-clearfix">
+	        __summary__
+	    </div> 
+	</div>
+</div>

+ 28 - 1
modules/boonex/files/template/unit_gallery.html

@@ -1 +1,28 @@
-<bx_include_base:../modules/base/text/template/unit_gallery.html />
+<div class="bx-files-text-unit-gallery bx-base-text-unit bx-base-text-unit-gallery bx-def-gal-unit-size bx-def-padding-sec bx-def-margin-sec-bottom">
+	<div class="bx-base-text-unit-cnt bx-def-box bx-def-round-corners bx-def-color-bg-box bx-def-box-sizing">
+		<div class="bx-base-text-unit-text bx-def-padding-leftright bx-def-padding-sec-topbottom bx-def-font-align-center bx-def-box-sizing">
+			<h2><a href="__content_url__">__title__</a></h2>
+		    <div class="bx-base-text-unit-info">
+		        <span class="bx-def-font-grayed">__entry_posting_date__</span>
+		        <span class="bx-base-text-unit-info-div bx-def-font-grayed">&#183;</span>
+		        <a class="bx-base-text-unit-author" href="__author_url__">__author__</a>
+		    </div>
+		</div>
+	    <bx_if:thumb>
+	        <a href="__content_url__" title="__summary_attr__">
+	            <div class="bx-base-text-unit-thumb bx-def-gal-div-size bx-def-round-corners bx-def-font-middle" style="background-image:url(__gallery_url__)">
+	                <div class="bx-base-text-unit-strecher">__strecher__</div>
+	            </div>
+	        </a>
+	    </bx_if:thumb>
+	    <bx_if:no_thumb>
+	        <div class="bx-def-gal-img-column">
+                <a href="__content_url__">
+    	            <div class="bx-base-text-unit-no-thumb bx-def-gal-div-size bx-def-font-middle bx-def-font-grayed bx-def-padding bx-def-box-sizing">
+                        <i class="sys-icon __icon__ "></i>
+    	            </div>
+                </a>
+	        </div>
+	    </bx_if:no_thumb>
+	</div>
+</div>

+ 21 - 0
modules/boonex/ocean/data/template/system/scripts/BxTemplFileHandlerCodeViewer.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolFileHandler
+ */
+class BxTemplFileHandlerCodeViewer extends BxBaseFileHandlerCodeViewer
+{    
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/ocean/data/template/system/scripts/BxTemplFileHandlerGoogleViewer.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolFileHandler
+ */
+class BxTemplFileHandlerGoogleViewer extends BxBaseFileHandlerGoogleViewer
+{    
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/ocean/data/template/system/scripts/BxTemplFileHandlerImagesViewer.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolFileHandler
+ */
+class BxTemplFileHandlerImagesViewer extends BxBaseFileHandlerImagesViewer
+{    
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/ocean/data/template/system/scripts/BxTemplFileHandlerMsViewer.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolFileHandler
+ */
+class BxTemplFileHandlerMsViewer extends BxBaseFileHandlerMsViewer
+{    
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/protean/data/template/system/scripts/BxTemplFileHandlerCodeViewer.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolFileHandler
+ */
+class BxTemplFileHandlerCodeViewer extends BxBaseFileHandlerCodeViewer
+{    
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/protean/data/template/system/scripts/BxTemplFileHandlerGoogleViewer.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolFileHandler
+ */
+class BxTemplFileHandlerGoogleViewer extends BxBaseFileHandlerGoogleViewer
+{    
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/protean/data/template/system/scripts/BxTemplFileHandlerImagesViewer.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolFileHandler
+ */
+class BxTemplFileHandlerImagesViewer extends BxBaseFileHandlerImagesViewer
+{    
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
modules/boonex/protean/data/template/system/scripts/BxTemplFileHandlerMsViewer.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolFileHandler
+ */
+class BxTemplFileHandlerMsViewer extends BxBaseFileHandlerMsViewer
+{    
+    public function __construct ($aObject, $oTemplate = false)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 5 - 1
modules/boonex/russian/data/langs/system/ru.xml

@@ -1736,7 +1736,11 @@
 	<string name="_sys_et_txt_subject_upgrade_success"><![CDATA[{site_name} - обновление успешно]]></string>
 	<string name="_sys_et_txt_subject_upgrade_modules_success"><![CDATA[Успешное обновление модулей на сайте {site_name}]]></string>
 	<string name="_sys_et_txt_subject_bg_operation_failed"><![CDATA[Фоновая операция не удалась]]></string>
-	<string name="_sys_et_txt_unsubscribe"><![CDATA[Отписаться]]></string>
+    <string name="_sys_et_txt_unsubscribe"><![CDATA[Отписаться]]></string>
+	<string name="_sys_file_handlers_ms_viewer"><![CDATA[Microsoft Office просмотрщик]]></string>
+	<string name="_sys_file_handlers_google_viewer"><![CDATA[Google просмотрщик]]></string>
+	<string name="_sys_file_handlers_images_viewer"><![CDATA[Просмотр изображений]]></string>
+	<string name="_sys_file_handlers_code_viewer"><![CDATA[Просмотр програмного кода]]></string>
 	<string name="_sys_form_account"><![CDATA[Аккаунт]]></string>
 	<string name="_sys_form_account_input_agreement"><![CDATA[]]></string>
 	<string name="_sys_form_account_input_agreement_value"><![CDATA[<div class="bx-def-font-small bx-def-font-grayed">Присоединяясь, Вы соглашаетесь с <a href="{0}">Правилами пользования</a> и <a href="{1}">Политикой конфиденциальности</a>.</div>]]></string>

+ 24 - 1
samples/storage.php

@@ -7,6 +7,29 @@
  * @{
  */
 
+/*
+ 
+INSERT INTO `sys_objects_storage` (`object`, `engine`, `params`, `token_life`, `cache_control`, `levels`, `table_files`, `ext_mode`, `ext_allow`, `ext_deny`, `quota_size`, `current_size`, `quota_number`, `current_number`, `max_file_size`, `ts`) VALUES
+('sample', 'Local', '', 360, 2592000, 0, 'sample', 'allow-deny', 'jpg,jpeg,jpe,gif,png,svg', '', 0, 0, 0, 0, 0, 0);
+
+CREATE TABLE IF NOT EXISTS `sample` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `profile_id` int(10) unsigned NOT NULL,
+  `remote_id` varchar(255) NOT NULL,
+  `path` varchar(255) NOT NULL,
+  `file_name` varchar(255) NOT NULL,
+  `mime_type` varchar(128) NOT NULL,
+  `ext` varchar(32) NOT NULL,
+  `size` int(11) NOT NULL,
+  `added` int(11) NOT NULL,
+  `modified` int(11) NOT NULL,
+  `private` int(11) NOT NULL,
+  PRIMARY KEY (`id`),
+  UNIQUE KEY `remote_id` (`remote_id`)
+);
+
+*/
+
 require_once('./../inc/header.inc.php');
 require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
 
@@ -36,7 +59,7 @@ function PageCompMainCode()
     BxDolStorage::pruning(); // pruning is needed to clear expired security tokens, you can call it on cron when your server is not busy
     $oStorage = BxDolStorage::getObjectInstance('sample');
 
-    //echo '<pre>reloadMimeTypesFromFile: [' . $oStorage->reloadMimeTypesFromFile(/*'/Users/alex/mime.types'*/'/etc/apache2/mime.types') . ']</pre>';
+    echo '<pre>reloadMimeTypesFromFile: [' . $oStorage->reloadMimeTypesFromFile(/*'/Users/alex/mime.types'*/'/etc/apache2/mime.types') . ']</pre>';
 
     if (isset($_POST['add'])) {
         $iId = $oStorage->storeFileFromForm($_FILES['file'], true, $iProfileId);

+ 14 - 0
template/css/file_handler.css

@@ -0,0 +1,14 @@
+.bx_file_handler_img {
+    width:100%;
+    height:auto;
+}
+
+.bx_file_handler_iframe {
+    width:100%;
+    height:50rem;
+}
+
+.bx_file_handler_code {
+    width:100%;
+    height:40rem;
+}

+ 10 - 0
template/file_handler_code.html

@@ -0,0 +1,10 @@
+<textarea class="bx_file_handler_code">__code__</textarea>
+<script>
+    var e = CodeMirror.fromTextArea($("textarea[class=bx_file_handler_code]").get(0), {
+        lineNumbers: true,
+        mode: "__mime_type__",
+        htmlMode: true,
+        matchBrackets: true,
+        readOnly: true
+    });
+</script>

+ 1 - 0
template/file_handler_iframe.html

@@ -0,0 +1 @@
+<iframe class="bx_file_handler_iframe __class__" src="__src__" frameborder="0"></iframe>

+ 1 - 0
template/file_handler_img.html

@@ -0,0 +1 @@
+<img class="bx_file_handler_img" src="__src__" />

+ 38 - 0
template/scripts/BxBaseFileHandler.php

@@ -0,0 +1,38 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaBaseView UNA Base Representation Classes
+ * @{
+ */
+
+/**
+ * @see BxDolFileHandler
+ */
+class BxBaseFileHandler extends BxDolFileHandler
+{
+    protected static $_isCssJsAdded = false;
+    
+    protected $_oTemplate;
+
+    public function __construct ($aObject, $oTemplate)
+    {
+        parent::__construct ($aObject);
+
+        if ($oTemplate)
+            $this->_oTemplate = $oTemplate;
+        else
+            $this->_oTemplate = BxDolTemplate::getInstance();
+    }
+
+    protected function addCssJs ()
+    {   
+        if (!self::$_isCssJsAdded) {
+            $this->_oTemplate->addCss('file_handler.css');
+            self::$_isCssJsAdded = true;
+        }
+    }
+}
+
+/** @} */

+ 43 - 0
template/scripts/BxBaseFileHandlerCodeViewer.php

@@ -0,0 +1,43 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaBaseView UNA Base Representation Classes
+ * @{
+ */
+
+/**
+ * Code viewer preview files with programming code inside.
+ * @see BxDolFileHandler
+ */
+class BxBaseFileHandlerCodeViewer extends BxBaseFileHandler
+{
+    protected static $_isCssJsAdded = false;
+
+    public function __construct ($aObject, $oTemplate)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+
+    public function display ($sFileUrl, $aFile)
+    {
+        $this->addCssJs();
+        return $this->_oTemplate->parseHtmlByName('file_handler_code.html', array(
+            'code' => htmlspecialchars(file_get_contents($sFileUrl)),
+            'mime_type' => $aFile['mime_type'],
+        ));
+    }
+
+    protected function addCssJs ()
+    {   
+        parent::addCssJs();
+        if (!self::$_isCssJsAdded) {
+    		$this->_oTemplate->addJs(array('codemirror/codemirror.min.js', ''));
+            $this->_oTemplate->addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'codemirror/|codemirror.css');
+            self::$_isCssJsAdded = true;
+        }
+    }
+}
+
+/** @} */

+ 31 - 0
template/scripts/BxBaseFileHandlerGoogleViewer.php

@@ -0,0 +1,31 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaBaseView UNA Base Representation Classes
+ * @{
+ */
+
+/**
+ * Google Viewer can preview pdf,doc,docx,xls,xlsx,ppt,pptx,pages,ai,psd,dxf,svg,eps,ps,ttf,xps,tif,tiff,zip,rar,txt,css,html,php,c,cpp,h,hpp,js files.
+ * @see BxDolFileHandler
+ */
+class BxBaseFileHandlerGoogleViewer extends BxBaseFileHandler
+{
+    public function __construct ($aObject, $oTemplate)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+
+    public function display ($sFileUrl, $aFile)
+    {
+        $this->addCssJs();
+        return $this->_oTemplate->parseHtmlByName('file_handler_iframe.html', array(
+            'class' => 'bx_file_handler_google_viewer',
+            'src' => 'https://docs.google.com/gview?url=' . rawurlencode($sFileUrl),
+        ));
+    }
+}
+
+/** @} */

+ 30 - 0
template/scripts/BxBaseFileHandlerImagesViewer.php

@@ -0,0 +1,30 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaBaseView UNA Base Representation Classes
+ * @{
+ */
+
+/**
+ * Images viewer preview image files.
+ * @see BxDolFileHandler
+ */
+class BxBaseFileHandlerImagesViewer extends BxBaseFileHandler
+{
+    public function __construct ($aObject, $oTemplate)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+
+    public function display ($sFileUrl, $aFile)
+    {
+        $this->addCssJs();
+        return $this->_oTemplate->parseHtmlByName('file_handler_img.html', array(
+            'src' => $sFileUrl,
+        ));
+    }
+}
+
+/** @} */

+ 31 - 0
template/scripts/BxBaseFileHandlerMsViewer.php

@@ -0,0 +1,31 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaBaseView UNA Base Representation Classes
+ * @{
+ */
+
+/**
+ * Microsoft Office Viewer for Word, Excel and PowerPoint documents.
+ * @see BxDolFileHandler
+ */
+class BxBaseFileHandlerMsViewer extends BxBaseFileHandler
+{    
+    public function __construct ($aObject, $oTemplate)
+    {
+        parent::__construct ($aObject, $oTemplate);
+    }
+
+    public function display ($sFileUrl, $aFile)
+    {
+        $this->addCssJs();
+        return $this->_oTemplate->parseHtmlByName('file_handler_iframe.html', array(
+            'class' => 'bx_file_handler_ms_viewer',
+            'src' => 'https://view.officeapps.live.com/op/embed.aspx?src=' . rawurlencode($sFileUrl),
+        ));
+    }
+}
+
+/** @} */

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio