-
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 #71 from JaroslawZielinski/feature/torahverse-input
TorahVerse Input
- Loading branch information
Showing
27 changed files
with
440 additions
and
509 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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JaroslawZielinski\TorahVerse\Block; | ||
|
||
use Magento\Framework\View\Element\Template; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use JaroslawZielinski\TorahVerse\Model\Config\Source\Verses\Translation as TranslationOptions; | ||
|
||
class Search extends Template | ||
{ | ||
/** | ||
* @var TranslationOptions | ||
*/ | ||
private $translationOptions; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function __construct( | ||
TranslationOptions $translationOptions, | ||
Context $context, | ||
array $data = [] | ||
) { | ||
$this->translationOptions = $translationOptions; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function _construct() | ||
{ | ||
$this->setTemplate('JaroslawZielinski_TorahVerse::search.phtml'); | ||
parent::_construct(); | ||
} | ||
|
||
public function getTranslations(): array | ||
{ | ||
return $this->translationOptions->toOptionArray(); | ||
} | ||
} |
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,77 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JaroslawZielinski\TorahVerse\Block\Siglum; | ||
|
||
use JaroslawZielinski\Torah\Translations\Resources; | ||
use JaroslawZielinski\TorahVerse\Model\Config; | ||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Directory\Helper\Data as DirectoryHelper; | ||
use Magento\Framework\Json\Helper\Data as JsonHelper; | ||
use Magento\Framework\View\Element\Template; | ||
|
||
class Info extends Template | ||
{ | ||
/** | ||
* @var Config | ||
*/ | ||
private $config; | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function __construct( | ||
Config $config, | ||
Context $context, | ||
array $data = [], | ||
?JsonHelper $jsonHelper = null, | ||
?DirectoryHelper $directoryHelper = null | ||
) { | ||
$this->config = $config; | ||
parent::__construct($context, $data, $jsonHelper, $directoryHelper); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function _construct() | ||
{ | ||
$this->setTemplate('JaroslawZielinski_TorahVerse::siglum/info.phtml'); | ||
parent::_construct(); | ||
} | ||
|
||
public function getBooksInfo(string $part = 'Tanakh'): array | ||
{ | ||
$results = []; | ||
$language = $this->config->getInternalizationLanguage(); | ||
array_filter(Resources::TORAH_BOOKS_EXTENDED[$part], function ($value, $key) use (&$results, $language) { | ||
$results[$key] = $value[$language]; | ||
}, ARRAY_FILTER_USE_BOTH); | ||
return $results; | ||
} | ||
|
||
private function pickBooks(array $rows, int $key, string $part): array | ||
{ | ||
$books = $this->getBooksInfo($part); | ||
$count = 0; | ||
foreach ($books as $code => $book) { | ||
$rows[$count][$key] = [$code => $book]; | ||
$count++; | ||
} | ||
return $rows; | ||
} | ||
|
||
public function getBooksRows(): array | ||
{ | ||
$rows = []; | ||
foreach ($this->getTorahParts() as $key => $part) { | ||
$rows = $this->pickBooks($rows, $key, $part); | ||
} | ||
return $rows; | ||
} | ||
|
||
public function getTorahParts(): array | ||
{ | ||
return array_keys(Resources::TORAH_BOOKS_EXTENDED); | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JaroslawZielinski\TorahVerse\Controller\Siglum; | ||
|
||
use Magento\Framework\App\Action\Action; | ||
use Magento\Framework\App\Action\Context; | ||
use Magento\Framework\View\Result\PageFactory; | ||
|
||
class Search extends Action | ||
{ | ||
/** | ||
* @var PageFactory | ||
*/ | ||
private $resultPageFactory; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function __construct( | ||
PageFactory $resultPageFactory, | ||
Context $context | ||
) { | ||
$this->resultPageFactory = $resultPageFactory; | ||
parent::__construct($context); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function execute() | ||
{ | ||
return $this->resultPageFactory->create(); | ||
} | ||
} |
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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace JaroslawZielinski\TorahVerse\Model\Config\Source\Verses; | ||
|
||
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource; | ||
use Magento\Framework\Data\OptionSourceInterface; | ||
|
||
class Division extends AbstractSource implements OptionSourceInterface | ||
{ | ||
public const MODE = [ | ||
'two-division' => 'Old Testamen/New Testament', | ||
'three-division' => 'Tanakh/Nevi\'im ketuvim/Brithadasha' | ||
]; | ||
|
||
public function getOptions(): array | ||
{ | ||
foreach (self::MODE as $position => $label) { | ||
$options[] = [ | ||
'label' => __($label), | ||
'value' => $position | ||
]; | ||
} | ||
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
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\Plugin\Backend\Model\Menu; | ||
|
||
use Magento\Backend\Model\Menu\Item; | ||
use Magento\Framework\UrlInterface; | ||
|
||
class ItemPlugin | ||
{ | ||
/** | ||
* @var UrlInterface | ||
*/ | ||
private $frontUrlModel; | ||
|
||
public function __construct(UrlInterface $frontUrlModel) | ||
{ | ||
$this->frontUrlModel = $frontUrlModel; | ||
} | ||
|
||
public function afterGetUrl(Item $subject, $result) | ||
{ | ||
$info = $subject->toArray(); | ||
if ('JaroslawZielinski_TorahVerse::versesearch' === $info['resource']) { | ||
return $this->frontUrlModel->getUrl($info['action']); | ||
} | ||
return $result; | ||
} | ||
} |
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
Oops, something went wrong.