![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/app/code/Xtento/StockImport/Block/Adminhtml/ |
<?php /** * Product: Xtento_StockImport * ID: u66QkJ5rBwmimhUzUElhIKqqWRvsbhC3WLqSMk5AjmQ= * Last Modified: 2021-04-25T18:52:14+00:00 * File: app/code/Xtento/StockImport/Block/Adminhtml/Manual.php * Copyright: Copyright (c) XTENTO GmbH & Co. KG <[email protected]> / All rights reserved. */ namespace Xtento\StockImport\Block\Adminhtml; class Manual extends \Magento\Backend\Block\Template { protected $importResult = false; /** * @var \Xtento\StockImport\Model\System\Config\Source\Import\Profile */ protected $profileSource; /** * @var \Xtento\StockImport\Helper\Entity */ protected $entityHelper; /** * @var \Magento\Store\Model\System\Store */ protected $systemStore; /** * @var \Magento\Framework\View\Element\Html\Date */ protected $dateElement; /** * @var \Xtento\StockImport\Model\ImportFactory */ protected $importFactory; /** * @var \Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface */ protected $dateTimeFormatter; /** * Manual constructor. * * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Store\Model\System\Store $systemStore * @param \Xtento\StockImport\Model\System\Config\Source\Import\Profile $profileSource * @param \Xtento\StockImport\Helper\Entity $entityHelper * @param \Magento\Framework\View\Element\Html\Date $dateElement * @param \Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface $dateTimeFormatter * @param \Xtento\StockImport\Model\ImportFactory $importFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Store\Model\System\Store $systemStore, \Xtento\StockImport\Model\System\Config\Source\Import\Profile $profileSource, \Xtento\StockImport\Helper\Entity $entityHelper, \Magento\Framework\View\Element\Html\Date $dateElement, \Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface $dateTimeFormatter, \Xtento\StockImport\Model\ImportFactory $importFactory, array $data = [] ) { parent::__construct($context, $data); $this->profileSource = $profileSource; $this->entityHelper = $entityHelper; $this->systemStore = $systemStore; $this->dateElement = $dateElement; $this->dateTimeFormatter = $dateTimeFormatter; $this->importFactory = $importFactory; } /** * @return void */ protected function _construct() { parent::_construct(); $this->setTemplate('Xtento_StockImport::manual_import.phtml'); } public function getJs($filename) { $url = $this->_assetRepo->createAsset( 'Xtento_StockImport::js/' . $filename, ['_secure' => $this->getRequest()->isSecure()] )->getUrl(); return $url; } public function getProfileSelectorHtml() { $html = '<select class="select" name="profile_id" id="profile_id" style="width: 320px;">'; $html .= '<option value="">' . __('--- Select Profile---') . '</option>'; $enabledProfiles = $this->profileSource->toOptionArray(); $profilesByGroup = []; foreach ($enabledProfiles as $profile) { $profilesByGroup[$profile['entity']][] = $profile; } foreach ($profilesByGroup as $entity => $profiles) { $html .= '<optgroup label="' . __( '%1 Import', $this->entityHelper->getEntityName($entity) ) . '">'; foreach ($profiles as $profile) { $html .= '<option value="' . $profile['value'] . '" entity="' . $entity . '">' . $profile['label'] . ' (' . __( 'ID: %1', $profile['value'] ) . ')</option>'; } $html .= '</optgroup>'; } $html .= '</select>'; return $html; } public function getSession() { return $this->_backendSession; } public function getImportResult() { if (!$this->importResult) { $this->importResult = $this->getSession()->getData('xtento_stockimport_debug_log'); $this->getSession()->setData('xtento_stockimport_debug_log', false); } if (empty($this->importResult)) { return false; } return $this->importResult; } protected function _toHtml() { $messagesBlock = <<<EOT <div id="messages"> <div class="messages"> <div class="message message-warning warning" id="warning-msg" style="display:none"> <div id="warning-msg-text"></div> </div> <div class="message message-success success" id="success-msg" style="display:none"> <div id="success-msg-text"></div> </div> </div> </div> EOT; return $messagesBlock . parent::_toHtml(); } /** * Escape string for the JavaScript context * * @param string $string * @return string * @since 101.0.0 */ public function escapeJs($string) { if ($string === '' || ctype_digit($string)) { return $string; } return preg_replace_callback( '/[^a-z0-9,\._]/iSu', function ($matches) { $chr = $matches[0]; if (strlen($chr) != 1) { $chr = mb_convert_encoding($chr, 'UTF-16BE', 'UTF-8'); $chr = ($chr === false) ? '' : $chr; } return sprintf('\\u%04s', strtoupper(bin2hex($chr))); }, $string ); } }