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

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhj committed Mar 12, 2019
2 parents 301d75c + 86bf9fe commit 2e3d8b5
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 56 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
"contao/core-bundle": "^4.4",
"menatwork/contao-multicolumnwizard-bundle": "^3.4"
},
"require-dev": {
"contao/manager-plugin": "^2.7"
},
"autoload": {
"psr-4": {
"Richardhj\\ContaoMultiColumnWizardFrontendBundle\\": "src/"
}
},
"extra": {
"contao-manager-plugin": "Richardhj\\ContaoMultiColumnWizardFrontendBundle\\ContaoManager\\Plugin",
"contao-manager-plugin": "Richardhj\\ContaoMultiColumnWizardFrontendBundle\\ContaoManager\\Plugin"
}
}
85 changes: 30 additions & 55 deletions src/Contao/Widget/FormMultiColumnWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

namespace Richardhj\ContaoMultiColumnWizardFrontendBundle\Contao\Widget;

use Contao\Controller;
use Contao\Environment;
use Contao\Widget;
use Contao\{StringUtil, System, Widget};


/**
Expand All @@ -26,22 +24,10 @@
class FormMultiColumnWizard extends \MenAtWork\MultiColumnWizardBundle\Contao\Widgets\MultiColumnWizard
{

/**
* Template
*
* @var string
*/
protected $strTemplate = 'form_mcw';


/**
* The CSS class prefix
*
* @var string
*/
protected $strPrefix = 'widget widget-mcw';


/** @noinspection PhpMissingParentConstructorInspection
* Don't use parent's but parent parent's __construct
*
Expand All @@ -51,6 +37,8 @@ public function __construct($arrAttributes = null)
{
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
Widget::__construct($arrAttributes);

$this->eventDispatcher = System::getContainer()->get('event_dispatcher');
}

public function generate($overwriteRowCurrentRow = null, $onlyRows = false): string
Expand All @@ -59,7 +47,8 @@ public function generate($overwriteRowCurrentRow = null, $onlyRows = false): str

unset($GLOBALS['TL_JAVASCRIPT']['mcw'], $GLOBALS['TL_CSS']['mcw']);

$GLOBALS['TL_JQUERY']['mcw_fe'] = 'bundles/richardhjcontaomulticolumnwizardfrontend/jquery.multicolumnwizard_fe.js';
$GLOBALS['TL_JQUERY']['mcw_fe'] =
'bundles/richardhjcontaomulticolumnwizardfrontend/jquery.multicolumnwizard_fe.js';

return $return;
}
Expand All @@ -72,24 +61,23 @@ protected function generateTable(
$arrItems,
$arrHiddenHeader = array(),
$onlyRows = false
)
{
$return = parent::generateTable($arrUnique, $arrDatepicker, $arrColorpicker, $strHidden, $arrItems, $arrHiddenHeader, $onlyRows);

// fixme does not work
$return = preg_replace('/<script(.*?)>(.*?)<\/script>/im', '', $return);
): string {
$return = parent::generateTable(
$arrUnique,
$arrDatepicker,
$arrColorpicker,
$strHidden,
$arrItems,
$arrHiddenHeader,
$onlyRows
);

$return = preg_replace('/<script(.*?)>([\s\S]*?)<\/script>/im', '', $return);

return $return;
}

/**
* Generate button string
*
* @param int $level
*
* @return string
*/
protected function generateButtonString($level = 0)
protected function generateButtonString($level = 0): string
{
$return = '';

Expand All @@ -100,41 +88,28 @@ protected function generateButtonString($level = 0)
}

$return .= sprintf(
'<a data-operations="%s" href="%s" class="widgetImage" title="%s">%s</a> ',
'<a data-operations="%s" href="#" class="widgetImage" title="%s">%s</a> ',
$button,
str_replace(
'index.php',
strtok(Environment::get('requestUri'), '?'),
Controller::addToUrl(
http_build_query(
[
$this->strCommand => $button,
'cid' => $level,
'id' => $this->currentRecord,
]
),
false
)
),
$GLOBALS['TL_LANG']['MSC']['tw_r' . specialchars($button)],
$GLOBALS['TL_LANG']['MSC']['tw_r' . StringUtil::specialchars($button)],
$this->getButtonContent($button) # We don't want to output an image and don't provide $image
);
}

return $return;
}


/**
* Get the content of the button, either text or image
*
* @param string $button The button name
*
* @return string
*/
protected function getButtonContent($button)
protected function getButtonContent($button): string
{
return '<span class="button ' . $button . '"></span>';
}

protected function getMcWDatePickerString(
$fieldId,
$fieldName,
$rgxp = null,
$fieldConfiguration = null,
$tableName = null
): string {
return '';
}
}
27 changes: 27 additions & 0 deletions src/ContaoManager/Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Richardhj\ContaoMultiColumnWizardFrontendBundle\ContaoManager;

use Contao\CoreBundle\ContaoCoreBundle;
use Contao\ManagerPlugin\Bundle\BundlePluginInterface;
use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
use MenAtWork\MultiColumnWizardBundle\MultiColumnWizardBundle;
use Richardhj\ContaoMultiColumnWizardFrontendBundle\RichardhjContaoMultiColumnWizardFrontendBundle;

class Plugin implements BundlePluginInterface
{

public function getBundles(ParserInterface $parser): array
{
return [
BundleConfig::create(RichardhjContaoMultiColumnWizardFrontendBundle::class)
->setLoadAfter(
[
ContaoCoreBundle::class,
MultiColumnWizardBundle::class
]
)
];
}
}

0 comments on commit 2e3d8b5

Please sign in to comment.