Skip to content

Commit

Permalink
Merge pull request #30 from contao-themes-net/fix/web-folder
Browse files Browse the repository at this point in the history
Fix/web folder
  • Loading branch information
MDevster authored Mar 9, 2022
2 parents 9371ff0 + bb8a290 commit c57aada
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 26 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Changelog

## [2.0.1](https://github.com/contao-themes-net/odd-theme-bundle/tree/2.0.1) – 2022-02-18
## [2.0.1](https://github.com/contao-themes-net/odd-theme-bundle/tree/2.0.1) – 2022-03-09

- [fix] add support for Symfony 5 public entry point
- [fix] change bundle namespace
- [fix] update fe_page template

## [2.0.0](https://github.com/contao-themes-net/odd-theme-bundle/tree/2.0.0) – 2022-02-17
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"autoload": {
"psr-4": {
"Pdir\\ThemeOddBundle\\": "src/"
"ContaoThemesNet\\ThemeOddBundle\\": "src/"
},
"classmap": [
"src/Resources/contao/"
Expand All @@ -53,7 +53,7 @@
]
},
"extra": {
"contao-manager-plugin": "Pdir\\ThemeOddBundle\\ContaoManagerPlugin"
"contao-manager-plugin": "ContaoThemesNet\\ThemeOddBundle\\ContaoManagerPlugin"
},
"funding": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/ContaoManagerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* file that was distributed with this source code.
*/

namespace Pdir\ThemeOddBundle;
namespace ContaoThemesNet\ThemeOddBundle;

use Contao\CoreBundle\ContaoCoreBundle;
use Contao\ManagerPlugin\Bundle\BundlePluginInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Element/SliderElement.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Pdir\ThemeOddBundle\Element;
namespace ContaoThemesNet\ThemeOddBundle\Element;

class SliderElement extends \ContentElement
{
Expand Down
14 changes: 9 additions & 5 deletions src/Module/OddThemeSetup.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace Pdir\ThemeOddBundle\Module;
namespace ContaoThemesNet\ThemeOddBundle\Module;

use ContaoThemesNet\ThemeOddBundle\ThemeUtils;

class OddThemeSetup extends \BackendModule
{
Expand All @@ -15,12 +17,14 @@ protected function compile()
{
switch (\Input::get('act')) {
case 'syncFolder':
$path = TL_ROOT . '/web/bundles/pdirthemeodd';
$path = sprintf('%s/%s/bundles/pdirthemeodd',
ThemeUtils::getRootDir(),
ThemeUtils::getWebDir());
if(!file_exists("files/odd")) {
new \Folder("files/odd");
}
$this->getFiles($path);
$this->getSqlFiles($path = TL_ROOT . "/vendor/contao-themes-net/odd-theme-bundle/src/templates");
$this->getSqlFiles(ThemeUtils::getRootDir() . "/vendor/contao-themes-net/odd-theme-bundle/src/templates");
$this->Template->message = true;
$this->Template->version = OddThemeSetup::VERSION;
$this->import('Automator');
Expand All @@ -45,8 +49,8 @@ protected function getFiles($path) {
$filesFolder = "files/odd".str_replace("pdirthemeodd","",substr($path,$pos))."/".$dir;

if($dir != "_odd_variables.scss" && $dir != "_odd_colors.scss" && $dir != "backend.css" && $dir != "odd.scss" && $dir != "responsive.scss" && $dir != "maklermodul.scss" && $dir != "odd_win.scss" && $dir != "style.scss") {
if(!file_exists(TL_ROOT."/".$filesFolder)) {
$objFile = new \File("web/bundles/".substr($path,$pos)."/".$dir, true);
if(!file_exists(ThemeUtils::getRootDir()."/".$filesFolder)) {
$objFile = new \File(ThemeUtils::getWebDir()."/bundles/".substr($path,$pos)."/".$dir, true);
$objFile->copyTo($filesFolder);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/PdirThemeOddBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* file that was distributed with this source code.
*/

namespace Pdir\ThemeOddBundle;
namespace ContaoThemesNet\ThemeOddBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/contao/config/config.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use Pdir\ThemeOddBundle\Element\SliderElement;
use ContaoThemesNet\ThemeOddBundle\Element\SliderElement;

// Insert the mate theme category
array_insert($GLOBALS['TL_CTE'], 1, array('themeOdd' => array()));
Expand Down Expand Up @@ -43,7 +43,7 @@
(
'oddThemeSetup' => array
(
'callback' => 'Pdir\\ThemeOddBundle\\Module\\OddThemeSetup',
'callback' => 'ContaoThemesNet\\ThemeOddBundle\\Module\\OddThemeSetup',
'tables' => array(),
'stylesheet' => 'bundles/pdirthemeodd/scss/backend.css'
),
Expand Down
14 changes: 1 addition & 13 deletions src/Resources/contao/templates/layout/fe_page_odd.html5
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,7 @@
<?= $this->head ?>
<?php $this->endblock(); ?>

<link rel="stylesheet" type="text/css" media="all" href="<?php
// add stylesheets
$combiner = new Combiner();
$combiner->add('bundles/pdirthemeodd/bootstrap/dist/css/bootstrap.min.css');

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$combiner->add('bundles/pdirthemeodd/scss/odd_win.scss');
} else {
$combiner->add('bundles/pdirthemeodd/scss/odd.scss');
}

echo $combiner->getCombinedFile(); ?>">

<link rel="stylesheet" type="text/css" media="all" href="<?= ContaoThemesNet\ThemeOddBundle\ThemeUtils::getCombinedStylesheet(); // odd theme css optimization ?>">
</head>
<body id="top"<?php if ($this->class): ?> class="<?= $this->class ?>"<?php endif; ?><?php if ($this->onload): ?> onload="<?= $this->onload ?>"<?php endif; ?>>

Expand Down
34 changes: 34 additions & 0 deletions src/ThemeUtils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace ContaoThemesNet\ThemeOddBundle;

use Contao\Combiner;
use Contao\File;
use Contao\System;
use Contao\StringUtil;

class ThemeUtils
{
public static function getRootDir() {
return System::getContainer()->getParameter('kernel.project_dir');
}

public static function getWebDir() {
return StringUtil::stripRootDir(System::getContainer()->getParameter('contao.web_dir'));
}

public static function getCombinedStylesheet() {

// add stylesheets
$combiner = new Combiner();
$combiner->add('bundles/pdirthemeodd/bootstrap/dist/css/bootstrap.min.css');

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$combiner->add('bundles/pdirthemeodd/scss/odd_win.scss');
} else {
$combiner->add('bundles/pdirthemeodd/scss/odd.scss');
}

return $combiner->getCombinedFile();
}
}

0 comments on commit c57aada

Please sign in to comment.