mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 15:37:03 +03:00
Code refactoring
a lot of small fixes (Closes #173) Added login field (ownCloud package)
This commit is contained in:
parent
a059b3d063
commit
fed896776f
129 changed files with 1016 additions and 804 deletions
|
|
@ -60,7 +60,7 @@ class HtmlUtils
|
|||
{
|
||||
$sHtmlAttrs = $aMatch[1];
|
||||
}
|
||||
|
||||
|
||||
$aMatch = array();
|
||||
if (preg_match('/<body([^>]+)>/im', $sHtml, $aMatch) && !empty($aMatch[1]))
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ class HtmlUtils
|
|||
$sHtml = \preg_replace('/<\/body>/im', '', $sHtml);
|
||||
$sHtml = \preg_replace('/<html([^>]*)>/im', '', $sHtml);
|
||||
$sHtml = \preg_replace('/<\/html>/im', '', $sHtml);
|
||||
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
|
|
@ -83,8 +83,8 @@ class HtmlUtils
|
|||
public static function ClearTags($sHtml)
|
||||
{
|
||||
$aRemoveTags = array(
|
||||
'head', 'link', 'base', 'meta', 'title', 'style', 'script', 'bgsound',
|
||||
'object', 'embed', 'applet', 'mocha', 'iframe', 'frame', 'frameset'
|
||||
'head', 'link', 'base', 'meta', 'title', 'style', 'script', 'bgsound', 'keygen', 'source',
|
||||
'object', 'embed', 'applet', 'mocha', 'iframe', 'frame', 'frameset', 'video', 'audio'
|
||||
);
|
||||
|
||||
$aToRemove = array(
|
||||
|
|
@ -116,6 +116,7 @@ class HtmlUtils
|
|||
'/on(DblClick)/si',
|
||||
'/on(Error)/si',
|
||||
'/on(Focus)/si',
|
||||
'/on(FormChange)/si',
|
||||
'/on(KeyDown)/si',
|
||||
'/on(KeyPress)/si',
|
||||
'/on(KeyUp)/si',
|
||||
|
|
@ -418,7 +419,7 @@ class HtmlUtils
|
|||
foreach ($aNodes as /* @var $oElement \DOMElement */ $oElement)
|
||||
{
|
||||
$sTagNameLower = \strtolower($oElement->tagName);
|
||||
|
||||
|
||||
// convert body attributes to styles
|
||||
if ('body' === $sTagNameLower)
|
||||
{
|
||||
|
|
@ -429,7 +430,7 @@ class HtmlUtils
|
|||
'bottommargin' => '',
|
||||
'rightmargin' => ''
|
||||
);
|
||||
|
||||
|
||||
if (isset($oElement->attributes))
|
||||
{
|
||||
foreach ($oElement->attributes as $sAttributeName => /* @var $oAttributeNode \DOMNode */ $oAttributeNode)
|
||||
|
|
@ -451,7 +452,7 @@ class HtmlUtils
|
|||
if (\is_array($aItem))
|
||||
{
|
||||
$oElement->removeAttribute($aItem[0]);
|
||||
|
||||
|
||||
switch ($sIndex)
|
||||
{
|
||||
case 'text':
|
||||
|
|
@ -484,7 +485,7 @@ class HtmlUtils
|
|||
{
|
||||
$oElement->setAttribute('src', 'javascript:false');
|
||||
}
|
||||
|
||||
|
||||
if (\in_array($sTagNameLower, array('a', 'form', 'area')))
|
||||
{
|
||||
$oElement->setAttribute('target', '_blank');
|
||||
|
|
@ -500,12 +501,22 @@ class HtmlUtils
|
|||
// $oElement->removeAttribute('style');
|
||||
// }
|
||||
|
||||
@$oElement->removeAttribute('id');
|
||||
@$oElement->removeAttribute('class');
|
||||
@$oElement->removeAttribute('contenteditable');
|
||||
@$oElement->removeAttribute('designmode');
|
||||
@$oElement->removeAttribute('data-bind');
|
||||
@$oElement->removeAttribute('xmlns');
|
||||
foreach (array(
|
||||
'id', 'class', 'contenteditable', 'designmode', 'formaction', 'data-bind', 'xmlns'
|
||||
) as $sAttr)
|
||||
{
|
||||
@$oElement->removeAttribute($sAttr);
|
||||
}
|
||||
|
||||
foreach (array(
|
||||
'load', 'blur', 'error', 'focus', 'formchange', 'change',
|
||||
'click', 'dblclick', 'keydown', 'keypress', 'keyup',
|
||||
'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup',
|
||||
'move', 'resize', 'resizeend', 'resizestart', 'scroll', 'select', 'submit', 'upload'
|
||||
) as $sAttr)
|
||||
{
|
||||
@$oElement->removeAttribute('on'.$sAttr);
|
||||
}
|
||||
|
||||
if ($oElement->hasAttribute('href'))
|
||||
{
|
||||
|
|
@ -544,7 +555,7 @@ class HtmlUtils
|
|||
{
|
||||
$oElement->setAttribute('data-x-src', $sSrc);
|
||||
}
|
||||
|
||||
|
||||
$bHasExternals = true;
|
||||
}
|
||||
else if ('data:image/' === \strtolower(\substr(\trim($sSrc), 0, 11)))
|
||||
|
|
@ -626,7 +637,7 @@ class HtmlUtils
|
|||
foreach ($aNodes as /* @var $oElement \DOMElement */ $oElement)
|
||||
{
|
||||
$sTagNameLower = \strtolower($oElement->tagName);
|
||||
|
||||
|
||||
if ($oElement->hasAttribute('data-x-src-cid'))
|
||||
{
|
||||
$sCid = $oElement->getAttribute('data-x-src-cid');
|
||||
|
|
@ -640,7 +651,7 @@ class HtmlUtils
|
|||
$oElement->setAttribute('src', 'cid:'.$sCid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($oElement->hasAttribute('data-x-src-location'))
|
||||
{
|
||||
$sSrc = $oElement->getAttribute('data-x-src-location');
|
||||
|
|
@ -838,10 +849,10 @@ class HtmlUtils
|
|||
|
||||
return $sText;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $sText
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function ConvertHtmlToPlain($sText)
|
||||
|
|
@ -937,7 +948,7 @@ class HtmlUtils
|
|||
'\'',
|
||||
''
|
||||
), $sText);
|
||||
|
||||
|
||||
$sText = str_ireplace('<div>',"\n<div>", $sText);
|
||||
$sText = strip_tags($sText, '');
|
||||
$sText = preg_replace("/\n\\s+\n/", "\n", $sText);
|
||||
|
|
|
|||
|
|
@ -1295,7 +1295,7 @@ class Actions
|
|||
$aResult['Language'] = $this->ValidateLanguage($sLanguage);
|
||||
$aResult['UserLanguage'] = $bUserLanguage;
|
||||
$aResult['LangLink'] = APP_INDEX_FILE.'?/Lang/0/'.($bAdmin ? 'en' : $aResult['Language']).'/'.$sStaticCache.'/';
|
||||
$aResult['TemplatesLink'] = APP_INDEX_FILE.'?/Templates/0/'.$sStaticCache.'/';
|
||||
$aResult['TemplatesLink'] = APP_INDEX_FILE.'?/Templates/0/'.($bAdmin ? 'Admin' : 'App').'/'.$sStaticCache.'/';
|
||||
$aResult['PluginsLink'] = $sPluginsLink;
|
||||
$aResult['EditorDefaultType'] = 'Html' === $aResult['EditorDefaultType'] ? 'Html' : 'Plain';
|
||||
|
||||
|
|
@ -6079,7 +6079,10 @@ class Actions
|
|||
{
|
||||
$oConfig = $this->Config();
|
||||
|
||||
$aResult = array(\RainLoop\Enumerations\Capa::PREM);
|
||||
$aResult = array(
|
||||
\RainLoop\Enumerations\Capa::PREM,
|
||||
\RainLoop\Enumerations\Capa::FILTERS
|
||||
);
|
||||
|
||||
if ($oConfig->Get('webmail', 'allow_additional_accounts', false))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace RainLoop\Enumerations;
|
||||
|
||||
class Capa
|
||||
{
|
||||
const PREM = 'PREM';
|
||||
const TWO_FACTOR = 'TWO_FACTOR';
|
||||
const OPEN_PGP = 'OPEN_PGP';
|
||||
const PREFETCH = 'PREFETCH';
|
||||
const GRAVATAR = 'GRAVATAR';
|
||||
const THEMES = 'THEMES';
|
||||
const ADDITIONAL_ACCOUNTS = 'ADDITIONAL_ACCOUNTS';
|
||||
const ADDITIONAL_IDENTITIES = 'ADDITIONAL_IDENTITIES';
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace RainLoop\Enumerations;
|
||||
|
||||
class Capa
|
||||
{
|
||||
const PREM = 'PREM';
|
||||
const TWO_FACTOR = 'TWO_FACTOR';
|
||||
const OPEN_PGP = 'OPEN_PGP';
|
||||
const PREFETCH = 'PREFETCH';
|
||||
const GRAVATAR = 'GRAVATAR';
|
||||
const THEMES = 'THEMES';
|
||||
const FILTERS = 'FILTERS';
|
||||
const ADDITIONAL_ACCOUNTS = 'ADDITIONAL_ACCOUNTS';
|
||||
const ADDITIONAL_IDENTITIES = 'ADDITIONAL_IDENTITIES';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ class ServiceActions
|
|||
*/
|
||||
protected $aPaths;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $sQuery;
|
||||
|
||||
/**
|
||||
* @param \MailSo\Base\Http $oHttp
|
||||
* @param \RainLoop\Actions $oActions
|
||||
|
|
@ -30,6 +35,7 @@ class ServiceActions
|
|||
$this->oHttp = $oHttp;
|
||||
$this->oActions = $oActions;
|
||||
$this->aPaths = array();
|
||||
$this->sQuery = '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -449,16 +455,18 @@ class ServiceActions
|
|||
$this->oActions->verifyCacheByKey($this->sQuery);
|
||||
}
|
||||
|
||||
$bAdmin = false !== \strpos($this->sQuery, 'Admin');
|
||||
|
||||
$sCacheFileName = '';
|
||||
if ($bCacheEnabled)
|
||||
{
|
||||
$sCacheFileName = 'TEMPLATES:'.$this->oActions->Plugins()->Hash().APP_VERSION;
|
||||
$sCacheFileName = 'TEMPLATES:'.($bAdmin ? 'Admin/' : 'App/').$this->oActions->Plugins()->Hash().APP_VERSION;
|
||||
$sResult = $this->Cacher()->Get($sCacheFileName);
|
||||
}
|
||||
|
||||
if (0 === \strlen($sResult))
|
||||
{
|
||||
$sResult = $this->compileTemplates(false);
|
||||
$sResult = $this->compileTemplates($bAdmin);
|
||||
if ($bCacheEnabled && 0 < \strlen($sCacheFileName))
|
||||
{
|
||||
$this->Cacher()->Set($sCacheFileName, $sResult);
|
||||
|
|
@ -1021,20 +1029,16 @@ class ServiceActions
|
|||
|
||||
/**
|
||||
* @param bool $bAdmin = false
|
||||
* @param bool $bWrapByScriptTag = true
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function compileTemplates($bAdmin = false, $bWrapByScriptTag = false)
|
||||
private function compileTemplates($bAdmin = false)
|
||||
{
|
||||
$sHtml = \RainLoop\Utils::CompileTemplates(APP_VERSION_ROOT_PATH.'app/templates/Views', $this->oActions).
|
||||
$sHtml = \RainLoop\Utils::CompileTemplates(APP_VERSION_ROOT_PATH.'app/templates/Views/'.($bAdmin ? 'Admin' : 'App'), $this->oActions).
|
||||
\RainLoop\Utils::CompileTemplates(APP_VERSION_ROOT_PATH.'app/templates/Views/Common', $this->oActions).
|
||||
$this->oActions->Plugins()->CompileTemplate($bAdmin);
|
||||
|
||||
return
|
||||
($bWrapByScriptTag ? '<script type="text/javascript" data-cfasync="false">' : '').
|
||||
'window.rainloopTEMPLATES='.\MailSo\Base\Utils::Php2js(array($sHtml)).';'.
|
||||
($bWrapByScriptTag ? '</script>' : '')
|
||||
;
|
||||
return 'window.rainloopTEMPLATES='.\MailSo\Base\Utils::Php2js(array($sHtml)).';';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue