feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
- Base: wintercms/winter branch 1.2 (full framework) - Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS - Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication - Partials: hero (offline-first), features, modes (offline/nube toggle), screenshots, pricing (3 planes), comparison, FAQ, CTA - Plugin VivesPOS.Site with ContactForm - Dockerfile: PHP 8.2 Apache, port 80, healthcheck - Added winter/wn-pages, blog, sitemap, seo plugins - Active theme set to vivespos
This commit is contained in:
127
modules/cms/classes/ThemeManager.php
Normal file
127
modules/cms/classes/ThemeManager.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php namespace Cms\Classes;
|
||||
|
||||
use File;
|
||||
use ApplicationException;
|
||||
use System\Models\Parameter;
|
||||
use Cms\Classes\Theme as CmsTheme;
|
||||
|
||||
/**
|
||||
* Theme manager
|
||||
*
|
||||
* @package winter\wn-cms-module
|
||||
* @author Alexey Bobkov, Samuel Georges
|
||||
*/
|
||||
class ThemeManager
|
||||
{
|
||||
use \Winter\Storm\Support\Traits\Singleton;
|
||||
|
||||
//
|
||||
// Gateway spawned
|
||||
//
|
||||
|
||||
/**
|
||||
* Returns a collection of themes installed via the update gateway
|
||||
* @return array
|
||||
*/
|
||||
public function getInstalled()
|
||||
{
|
||||
return Parameter::get('system::theme.history', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a theme has ever been installed before.
|
||||
* @param string $name Theme code
|
||||
* @return boolean
|
||||
*/
|
||||
public function isInstalled($name)
|
||||
{
|
||||
return array_key_exists($name, Parameter::get('system::theme.history', []));
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags a theme as being installed, so it is not downloaded twice.
|
||||
* @param string $code Theme code
|
||||
* @param string|null $dirName
|
||||
*/
|
||||
public function setInstalled($code, $dirName = null)
|
||||
{
|
||||
if (!$dirName) {
|
||||
$dirName = strtolower(str_replace('.', '-', $code));
|
||||
}
|
||||
|
||||
$history = Parameter::get('system::theme.history', []);
|
||||
$history[$code] = $dirName;
|
||||
Parameter::set('system::theme.history', $history);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags a theme as being uninstalled.
|
||||
* @param string $code Theme code
|
||||
*/
|
||||
public function setUninstalled($code)
|
||||
{
|
||||
$history = Parameter::get('system::theme.history', []);
|
||||
if (array_key_exists($code, $history)) {
|
||||
unset($history[$code]);
|
||||
}
|
||||
|
||||
Parameter::set('system::theme.history', $history);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an installed theme's code from it's dirname.
|
||||
* @return string
|
||||
*/
|
||||
public function findByDirName($dirName)
|
||||
{
|
||||
$installed = $this->getInstalled();
|
||||
foreach ($installed as $code => $name) {
|
||||
if ($dirName == $name) {
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// Management
|
||||
//
|
||||
|
||||
/**
|
||||
* Completely delete a theme from the system.
|
||||
* @param string $theme Theme code/namespace
|
||||
* @return void
|
||||
*/
|
||||
public function deleteTheme($theme)
|
||||
{
|
||||
if (!$theme) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_string($theme)) {
|
||||
$theme = CmsTheme::load($theme);
|
||||
}
|
||||
|
||||
if ($theme->isActiveTheme()) {
|
||||
throw new ApplicationException(trans('cms::lang.theme.delete_active_theme_failed'));
|
||||
}
|
||||
|
||||
$theme->removeCustomData();
|
||||
|
||||
/*
|
||||
* Delete from file system
|
||||
*/
|
||||
$themePath = $theme->getPath();
|
||||
if (File::isDirectory($themePath)) {
|
||||
File::deleteDirectory($themePath);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set uninstalled
|
||||
*/
|
||||
if ($themeCode = $this->findByDirName($theme->getDirName())) {
|
||||
$this->setUninstalled($themeCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user