Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

Commit

Permalink
Initial release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugen committed Jun 27, 2018
0 parents commit 90c5fc9
Show file tree
Hide file tree
Showing 14 changed files with 1,667 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions Core/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* This file is part of WEA IT-Solutions wea_assets_management module.
*
* WEA IT-Solutions wea_assets_management module is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WEA IT-Solutions wea_assets_management module 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WEA IT-Solutions wea_assets_management module. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://www.wea-it.com
* @copyright (C) WEA IT-Solutions 2018
*/


namespace WeaItSolutions\Oxid\AssetsManagement\Core;

class Config extends Config_parent
{
/**
* Returns cdn url if configured.
*
* @param null $ssl
* @param null $admin
* @param bool $nativeImg
* @return mixed
*/
public function getOutUrl($ssl = null, $admin = null, $nativeImg = false)
{
$sParentOutUrl = parent::getOutUrl($ssl, $admin, $nativeImg);
$admin = is_null($admin) ? $this->isAdmin() : $admin;
$ssl = is_null($ssl) ? $this->isSsl() : $ssl;
$sCdnUrl = $this->getConfig()->getConfigParam('wea_assets_mgnt_cdn');
if(!$admin && $sCdnUrl){
$sShopUrl = $this->getConfigParam('sShopURL');
if($ssl){
$sShopUrl = $this->getConfigParam('sSSLShopURL');
}

return str_replace(rtrim($sShopUrl, '/'), rtrim($sCdnUrl, '/'), $sParentOutUrl);
}

return $sParentOutUrl;
}
}
75 changes: 75 additions & 0 deletions Core/ViewConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
* This file is part of WEA IT-Solutions wea_assets_management module.
*
* WEA IT-Solutions wea_assets_management module is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WEA IT-Solutions wea_assets_management module 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WEA IT-Solutions wea_assets_management module. If not, see <http://www.gnu.org/licenses/>.
*
* @link http://www.wea-it.com
* @copyright (C) WEA IT-Solutions 2018
*/


namespace WeaItSolutions\Oxid\AssetsManagement\Core;


class ViewConfig extends ViewConfig_parent
{
/**
* Returns external cdn url if is one defined.
*
* @param $sModule
* @param string $sFile
* @return mixed
*/
public function getModuleUrl($sModule, $sFile = '')
{
if (!$this->isAdmin() && $this->getConfig()->getConfigParam('wea_assets_mgnt_cdn')) {
$sUrl = str_replace(
rtrim($this->getConfig()->getConfigParam('sShopDir'), '/'),
rtrim($this->getConfig()->getConfigParam('wea_assets_mgnt_cdn'), '/'),
$this->getModulePath($sModule, $sFile)
);
} else {
$sUrl = parent::getModuleUrl($sModule, $sFile);
}

return $sUrl;

}

/**
* @param null $sFile
* @return mixed
*/
public function getResourceUrl($sFile = null)
{
if (!$sFile && !$this->isAdmin() && $this->getViewConfigParam('basetpldir') === null) {
if ($sCdnUri = $this->getConfig()->getConfigParam('wea_assets_mgnt_cdn')) {
$sValue = $this->getConfig()->getResourceUrl('', $this->isAdmin());

if ($this->getConfig()->getConfigParam('blNativeImages')) {
$sCurrentUrl = $this->getConfig()->getSslShopUrl();
} else {
$sCurrentUrl = $this->getConfig()->getConfigParam('sSSLShopURL');
}

$sValue = str_replace($sCurrentUrl, $sCdnUri, $sValue);
$this->setViewConfigParam('basetpldir', $sValue);
}
}

return parent::getResourceUrl($sFile);

}
}
Loading

0 comments on commit 90c5fc9

Please sign in to comment.