-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from JaroslawZielinski/feature/138-widget-wit…
…h-static-selected-verse-tweak task #138: Widget with Static Selected Verse Tweak
- Loading branch information
Showing
9 changed files
with
239 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JaroslawZielinski\TorahVerse\Block\Widget\Email\Static; | ||
|
||
class Random extends \JaroslawZielinski\TorahVerse\Block\Widget\Static\Random | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function _construct(): void | ||
{ | ||
parent::_construct(); | ||
$this->setTemplate('JaroslawZielinski_TorahVerse::widget/email/slider.phtml'); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @throws \Exception | ||
*/ | ||
public function getConfig(): array | ||
{ | ||
$config = parent::getConfig(); | ||
$items = $config['items'] ?? []; | ||
$randomItemIndex = rand(0, count($items) - 1); | ||
$config['items'] = [$items[$randomItemIndex]]; | ||
return $config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JaroslawZielinski\TorahVerse\Block\Widget\Email\Static; | ||
|
||
/** | ||
* @method setLanguage(string $language): self | ||
* @method getEn(): string | ||
* @method getPl(): string | ||
*/ | ||
class Selected extends \JaroslawZielinski\TorahVerse\Block\Widget\Static\Selected | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function _construct(): void | ||
{ | ||
parent::_construct(); | ||
$this->setTemplate('JaroslawZielinski_TorahVerse::widget/email/slider.phtml'); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getItems(array $groupsArray = []): array | ||
{ | ||
$language = explode('_', $this->config->getStoreLocale()); | ||
$lang = $language[0]; | ||
$siglum = $this->getSiglum(); | ||
switch ($lang) { | ||
default: | ||
case 'en': | ||
$translation = $this->getEn(); | ||
$this->setLanguage('en'); | ||
break; | ||
case 'pl': | ||
$translation = $this->getPl(); | ||
$this->setLanguage('pl'); | ||
break; | ||
} | ||
$siglumParts = explode('/', $siglum); | ||
$siglumParts[0] = $translation; | ||
$this->setSiglum(implode('/', $siglumParts)); | ||
return parent::getItems($groupsArray); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JaroslawZielinski\TorahVerse\Model\Config\Source\Sliders; | ||
|
||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource; | ||
use Magento\Framework\Data\OptionSourceInterface; | ||
|
||
class Frontend extends AbstractSource implements OptionSourceInterface | ||
{ | ||
public const FRONTEND = 'frontend'; | ||
|
||
public const FRONTEND_OPTIONS = [ | ||
self::FRONTEND => [ | ||
'label' => 'Frontend', | ||
'value' => self::FRONTEND | ||
] | ||
]; | ||
|
||
public function getOptions(): array | ||
{ | ||
$options = []; | ||
foreach (self::FRONTEND_OPTIONS as $value => $option) { | ||
$options[] = ['label' => __($option['label']), 'value' => $value]; | ||
} | ||
return $options; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getAllOptions(): ?array | ||
{ | ||
if (empty($this->_options)) { | ||
$this->_options = $this->getOptions(); | ||
} | ||
return $this->_options; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
/** @var \JaroslawZielinski\TorahVerse\Block\Widget\Email\Static\Random|\JaroslawZielinski\TorahVerse\Block\Widget\Email\Static\Selected $block */ | ||
$config = $block->getConfig(); | ||
$customStyles = trim($block->getModuleCustomStyles() ?? ''); | ||
$backgroundHoverColour = $block->getBackgroundHoverColour() ?? 'none'; | ||
?> | ||
<?php if ($block->isVisible()): ?> | ||
<?php if (!empty($customStyles)): ?> | ||
<style type="text/css"> | ||
/* <![CDATA[ */ | ||
.verse-slider.paused-slider { | ||
background-color: <?= $backgroundHoverColour; ?>; | ||
} | ||
<?= $customStyles; ?> | ||
.verse-slider .slider, .verse-slider .item { height: auto; } | ||
/* ]]> */ | ||
</style> | ||
<?php endif; ?> | ||
<div class="verse-slider"> | ||
<?= $block->getItemFlatHtml($config); ?> | ||
</div> | ||
<?php endif; ?> |