mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
Issue #4471
This commit is contained in:
@@ -1667,14 +1667,28 @@ class media_admin_ui extends e_admin_ui
|
||||
private function mediaManagerPlaceholders()
|
||||
{
|
||||
$type = (E107_DEBUG_LEVEL > 0) ? 'text' : 'hidden';
|
||||
$br = (E107_DEBUG_LEVEL > 0) ? "<br style='clear:both' />" : '';
|
||||
|
||||
$text = '
|
||||
' .$br."<input title='bbcode' type='{$type}' style=readonly='readonly' class='span11 col-md-11' id='bbcode_holder' name='bbcode_holder' value='' />
|
||||
".$br."<input title='html/wysiwyg' type='{$type}' class='span11 col-md-11' readonly='readonly' id='html_holder' name='html_holder' value='' />
|
||||
".$br."<input title='(preview) src' type='{$type}' class='span11 col-md-11' readonly='readonly' id='src' name='src' value='' />
|
||||
".$br."<input title='path (saved to db)' type='{$type}' class='span11 col-md-11' readonly='readonly' id='path' name='path' value='' />
|
||||
";
|
||||
|
||||
$valueHolders = [
|
||||
'bbcode_holder' => 'bbcode',
|
||||
'html_holder' => 'html/wysiwyg',
|
||||
'src' => '(preview) src',
|
||||
'path' => 'path (save to db)'
|
||||
];
|
||||
|
||||
$text = '';
|
||||
foreach($valueHolders as $name => $label)
|
||||
{
|
||||
$text .= (E107_DEBUG_LEVEL > 0) ? "<br /><span style='margin-left:20px;display:inline-block;width:150px'>".$label." </span>" : '';
|
||||
$text .= "<input title='".$label."' type='{$type}' readonly style='width:800px' class='' id='".$name."' name='".$name."' value='' />\n";
|
||||
|
||||
}
|
||||
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
$text .= "<br /><span style='margin-left:20px;display:inline-block;width:150px'>FontAwesome</span>".e107::getTheme()->getFontAwesome();
|
||||
}
|
||||
|
||||
|
||||
return $text;
|
||||
}
|
||||
@@ -2117,6 +2131,9 @@ class media_admin_ui extends e_admin_ui
|
||||
|
||||
}
|
||||
|
||||
if($this->fontawesome === 4)
|
||||
{
|
||||
e107::getParser()->setFontAwesome(4);;
|
||||
$fa4 = e107::getMedia()->getGlyphs('fa4');
|
||||
|
||||
foreach($fa4 as $val)
|
||||
@@ -2131,7 +2148,7 @@ class media_admin_ui extends e_admin_ui
|
||||
'slideCategory' => 'font-awesome'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($this->fontawesome === false || ($this->fontawesome < 4))
|
||||
{
|
||||
|
@@ -1103,6 +1103,15 @@ class e_theme
|
||||
|
||||
unset($vars['libraries']);
|
||||
}
|
||||
else // detect defined constants in legacy theme.php file.
|
||||
{
|
||||
if($data = self::getLegacyBSFA($path))
|
||||
{
|
||||
$vars['library'] = $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(!empty($vars['stylesheets']['css']))
|
||||
{
|
||||
@@ -1158,6 +1167,37 @@ class e_theme
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read legacy bootstrap/fontawesome constants from theme.php
|
||||
* @param string $path theme directory
|
||||
*/
|
||||
public static function getLegacyBSFA($path)
|
||||
{
|
||||
if(!$content = file_get_contents(e_THEME.$path.'/theme.php'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$ret = [];
|
||||
|
||||
if(preg_match('/define[ ]*?\([\'|"]BOOTSTRAP[\'|"],[ \t]*(\d)\);/', $content, $m))
|
||||
{
|
||||
$ret[] = array('name' => 'bootstrap',
|
||||
'version' => $m[1],
|
||||
'scope' => 'front,wysiwyg',
|
||||
);
|
||||
}
|
||||
|
||||
if(preg_match('/define[ ]*?\([\'|"]FONTAWESOME[\'|"],[ \t]*(\d)\);/', $content, $m))
|
||||
{
|
||||
$ret[] = array('name' => 'fontawesome',
|
||||
'version' => $m[1],
|
||||
'scope' => 'front,wysiwyg',
|
||||
);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and return the name of the categories.
|
||||
|
@@ -114,7 +114,9 @@ TEMPL;
|
||||
public function toHTML($content)
|
||||
{
|
||||
$tp = e107::getParser();
|
||||
// XXX @Cam possible fix - convert to BB first, see news admin AJAX request/response values for reference why
|
||||
$fa = e107::getTheme()->getFontAwesome(); // get the frontend theme's fontawesome version.
|
||||
$tp->setFontAwesome($fa);
|
||||
|
||||
$content = stripslashes($content);
|
||||
|
||||
// $content = e107::getBB()->htmltoBBcode($content); //XXX This breaks inserted images from media-manager. :/
|
||||
|
@@ -943,12 +943,12 @@ class wysiwyg
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getEditorCSS()
|
||||
public function getEditorCSS($theme = 'front')
|
||||
{
|
||||
|
||||
$tp = e107::getParser();
|
||||
|
||||
$libraries = e107::getTheme('admin')->getThemeFiles('library', 'wysiwyg');
|
||||
$libraries = e107::getTheme($theme)->getThemeFiles('library', 'wysiwyg');
|
||||
|
||||
$ret = [];
|
||||
|
||||
@@ -967,7 +967,7 @@ class wysiwyg
|
||||
|
||||
if($useThemeStyle)
|
||||
{
|
||||
$theme = e107::getTheme()->getThemeFiles('css', 'wysiwyg');
|
||||
$theme = e107::getTheme($theme)->getThemeFiles('css', 'wysiwyg');
|
||||
if(!empty($theme['css']))
|
||||
{
|
||||
foreach($theme['css'] as $path)
|
||||
|
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class e_themeTest extends \Codeception\Test\Unit
|
||||
{
|
||||
|
||||
@@ -16,6 +15,7 @@
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
|
||||
// require_once(e_HANDLER."e_marketplace.php");
|
||||
try
|
||||
{
|
||||
@@ -49,6 +49,7 @@
|
||||
*/
|
||||
public function testGetScope()
|
||||
{
|
||||
|
||||
$tests = array(
|
||||
0 => array(
|
||||
'theme' => 'front',
|
||||
@@ -306,8 +307,7 @@
|
||||
|
||||
$expected = array(
|
||||
'css' =>
|
||||
array (
|
||||
),
|
||||
array(),
|
||||
);
|
||||
|
||||
$result = e107::getTheme('bootstrap3')->getThemeFiles('css', 'wysiwyg');
|
||||
@@ -318,9 +318,9 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testLoadLibrary()
|
||||
{
|
||||
|
||||
$tests = array(
|
||||
0 => array(
|
||||
'theme' => 'front',
|
||||
@@ -349,12 +349,11 @@
|
||||
// var_export($loaded);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
|
||||
$tests = array(
|
||||
0 => array(
|
||||
'theme' => 'front',
|
||||
@@ -434,6 +433,7 @@
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public function testParse_theme_php()
|
||||
{
|
||||
@@ -541,6 +541,7 @@
|
||||
// print_r($_SERVER);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public function testClearCache()
|
||||
{
|
||||
@@ -556,12 +557,110 @@
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
public function testParse_theme_xml()
|
||||
{
|
||||
$tests = array(
|
||||
'bootstrap3' => array(
|
||||
'library' => array (
|
||||
0 =>
|
||||
array (
|
||||
'name' => 'bootstrap',
|
||||
'version' => '3',
|
||||
'scope' => 'front,admin,wysiwyg',
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'name' => 'fontawesome',
|
||||
'version' => '5',
|
||||
'scope' => 'front,admin,wysiwyg',
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'name' => 'bootstrap.editable',
|
||||
'version' => '',
|
||||
'scope' => 'admin',
|
||||
),
|
||||
)
|
||||
|
||||
),
|
||||
'bootstrap5' => array(
|
||||
'library' => array (
|
||||
0 =>
|
||||
array (
|
||||
'name' => 'bootstrap',
|
||||
'version' => '5',
|
||||
'scope' => 'front',
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'name' => 'fontawesome',
|
||||
'version' => '5',
|
||||
'scope' => 'front',
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
'voux' => array( // theme using defines for FONTAWESOME and BOOTSTRAP
|
||||
'library' => array (
|
||||
0 =>
|
||||
array (
|
||||
'name' => 'bootstrap',
|
||||
'version' => '3',
|
||||
'scope' => 'front,wysiwyg',
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'name' => 'fontawesome',
|
||||
'version' => '4',
|
||||
'scope' => 'front,wysiwyg',
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
foreach($tests as $theme => $var)
|
||||
{
|
||||
$result = e_theme::parse_theme_xml($theme);
|
||||
foreach($var as $att => $value)
|
||||
{
|
||||
if(empty($value))
|
||||
{
|
||||
var_export($result[$att]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertSame($result[$att], $value);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testGetLegacyBSFA()
|
||||
{
|
||||
$result = e_theme::getLegacyBSFA('voux');
|
||||
|
||||
$expected = array (
|
||||
0 =>
|
||||
array (
|
||||
'name' => 'bootstrap',
|
||||
'version' => '3',
|
||||
'scope' => 'front,wysiwyg',
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'name' => 'fontawesome',
|
||||
'version' => '4',
|
||||
'scope' => 'front,wysiwyg',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
|
||||
require_once(e_PLUGIN . "tinymce4/wysiwyg_class.php");
|
||||
try
|
||||
{
|
||||
@@ -21,6 +22,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public function testGetExternalPlugins()
|
||||
{
|
||||
@@ -39,16 +41,39 @@
|
||||
|
||||
public function testGetEditorCSS()
|
||||
{
|
||||
$expected = array (
|
||||
|
||||
$tests = array(
|
||||
'bootstrap3' => array(
|
||||
0 => '/e107_web/lib/bootstrap/3/css/bootstrap.min.css',
|
||||
1 => '/e107_web/lib/font-awesome/5/css/all.min.css',
|
||||
2 => '/e107_web/lib/font-awesome/5/css/v4-shims.min.css',
|
||||
3 => '/e107_web/lib/animate.css/animate.min.css',
|
||||
4 => '/e107_plugins/tinymce4/editor.css',
|
||||
),
|
||||
'voux' => array (
|
||||
0 => '/e107_web/lib/bootstrap/3/css/bootstrap.min.css',
|
||||
1 => '/e107_web/lib/font-awesome/4.7.0/css/font-awesome.min.css',
|
||||
2 => '/e107_web/lib/animate.css/animate.min.css',
|
||||
3 => '/e107_plugins/tinymce4/editor.css',
|
||||
)
|
||||
|
||||
|
||||
);
|
||||
|
||||
$result = $this->tm->getEditorCSS();
|
||||
|
||||
foreach($tests as $themedir => $expected)
|
||||
{
|
||||
$result = $this->tm->getEditorCSS($themedir);
|
||||
|
||||
if(empty($expected))
|
||||
{
|
||||
var_export($result);
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
@@ -79,5 +104,4 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user