public function testGetUrl()
 {
     $this->mockDesign();
     $this->baseUrl->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://example.com/static/'));
     $result = $this->object->getUrl('Module_Name::img/product/placeholder.png');
     $this->assertEquals('http://example.com/static/area/theme/locale/Module_Name/img/product/placeholder.png', $result);
 }
Beispiel #2
0
    /**
     * Return element html code
     *
     * @return string
     */
    public function getElementHtml()
    {
        $htmlId = $this->_escaper->escapeHtml($this->getHtmlId());
        $uploadUrl = $this->_escaper->escapeHtml($this->_getUploadUrl());
        $spacerImage = $this->_assetRepo->getUrl('images/spacer.gif');
        $imagePlaceholderText = __('Click here or drag and drop to add images');
        $deleteImageText = __('Delete image');
        $makeBaseText = __('Make Base');
        $hiddenText = __('Hidden');
        $imageManagementText = __('Image Management');
        /** @var $product \Magento\Catalog\Model\Product */
        $html = <<<HTML
<div id="{$htmlId}-container" class="images"
    data-mage-init='{"baseImage":{}}'
    data-max-file-size="{$this->_getFileMaxSize()}"
    >
    <div class="image image-placeholder">
        <input type="file" name="image" data-url="{$uploadUrl}" multiple="multiple" />
        <img class="spacer" src="{$spacerImage}"/>
        <p class="image-placeholder-text">{$imagePlaceholderText}</p>
    </div>
    <script id="{$htmlId}-template" class="image-template" type="text/x-jquery-tmpl">
        <div class="image">
            <img class="spacer" src="{$spacerImage}"/>
            <img class="product-image" src="\${url}" data-position="\${position}" alt="\${label}" />
            <div class="actions">
                <button class="action-delete" data-role="delete-button" title="{$deleteImageText}">
                    <span>{$deleteImageText}</span>
                </button>
                <button class="action-make-base" data-role="make-base-button" title="{$makeBaseText}">
                    <span>{$makeBaseText}</span>
                </button>
                <div class="draggable-handle"></div>
            </div>
            <div class="image-label"></div>
            <div class="image-fade"><span>{$hiddenText}</span></div>
        </div>
    </script>
</div>
<span class="action-manage-images" data-activate-tab="image-management">
    <span>{$imageManagementText}</span>
</span>
<script>
    require([
        'jquery'
    ],function(\$){

        'use strict';

        \$('[data-activate-tab=image-management]')
            .on('click.toggleImageManagementTab', function() {
                \$('#product_info_tabs_image-management').trigger('click');
            });
    });
</script>

HTML;
        return $html;
    }
Beispiel #3
0
 /**
  * @return string
  */
 protected function getDefaultPlaceholderUrl()
 {
     try {
         $url = $this->_assetRepo->getUrl($this->getPlaceholder());
     } catch (\Exception $e) {
         $this->_logger->critical($e);
         $url = $this->_urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']);
     }
     return $url;
 }
 /**
  * @return void
  */
 public function testGetUrl()
 {
     $themeMock = $this->getMock('Magento\\Framework\\View\\Design\\ThemeInterface', [], [], '', false);
     $this->designMock->expects($this->any())->method('getDesignParams')->willReturn(['themeModel' => $themeMock, 'area' => 'area', 'locale' => 'locale']);
     $assetMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File')->disableOriginalConstructor()->getMock();
     $assetMock->expects($this->any())->method('getUrl')->willReturn('some url');
     $this->fileFactoryMock->expects($this->exactly(2))->method('create')->with(['source' => $this->sourceMock, 'context' => '', 'filePath' => 'test/file.js', 'module' => '', 'contentType' => ''])->willReturn($assetMock);
     $this->assertEquals('some url', $this->repository->getUrl('test/file.js'));
     $this->assertEquals('some url', $this->repository->getUrlWithParams('test/file.js', []));
 }
Beispiel #5
0
 /**
  * Retrieve small image url
  *
  * @param ModelProduct|\Magento\Framework\DataObject $product
  * @return string|bool
  */
 public function getSmallImageUrl($product)
 {
     $url = false;
     $attribute = $product->getResource()->getAttribute('small_image');
     if (!$product->getSmallImage()) {
         $url = $this->_assetRepo->getUrl('Magento_Catalog::images/product/placeholder/small_image.jpg');
     } elseif ($attribute) {
         $url = $attribute->getFrontend()->getUrl($product);
     }
     return $url;
 }
Beispiel #6
0
 /**
  * Return File preview link HTML
  *
  * @return string
  */
 protected function _getPreviewHtml()
 {
     $html = '';
     if ($this->getValue() && !is_array($this->getValue())) {
         $image = ['alt' => __('Download'), 'title' => __('Download'), 'src' => $this->_assetRepo->getUrl('images/fam_bullet_disk.gif'), 'class' => 'v-middle'];
         $url = $this->_getPreviewUrl();
         $html .= '<span>';
         $html .= '<a href="' . $url . '">' . $this->_drawElementHtml('img', $image) . '</a> ';
         $html .= '<a href="' . $url . '">' . __('Download') . '</a>';
         $html .= '</span>';
     }
     return $html;
 }
Beispiel #7
0
 /**
  * Get image URL of WYSIWYG placeholder image
  *
  * @param string $type
  * @return string
  */
 public function getPlaceholderImageUrl($type)
 {
     $placeholder = false;
     $widget = $this->getWidgetByClassType($type);
     if (is_array($widget) && isset($widget['placeholder_image'])) {
         $placeholder = (string) $widget['placeholder_image'];
     }
     if ($placeholder) {
         $asset = $this->assetRepo->createAsset($placeholder);
         $placeholder = $this->assetSource->getFile($asset);
         if ($placeholder) {
             return $asset->getUrl();
         }
     }
     return $this->assetRepo->getUrl('Magento_Widget::placeholder.gif');
 }
 /**
  * Return Wysiwyg config as \Magento\Framework\DataObject
  *
  * Config options description:
  *
  * enabled:                 Enabled Visual Editor or not
  * hidden:                  Show Visual Editor on page load or not
  * use_container:           Wrap Editor contents into div or not
  * no_display:              Hide Editor container or not (related to use_container)
  * translator:              Helper to translate phrases in lib
  * files_browser_*:         Files Browser (media, images) settings
  * encode_directives:       Encode template directives with JS or not
  *
  * @param array|\Magento\Framework\DataObject $data Object constructor params to override default config values
  * @return \Magento\Framework\DataObject
  */
 public function getConfig($data = [])
 {
     $config = new \Magento\Framework\DataObject();
     $config->setData(['enabled' => $this->isEnabled(), 'hidden' => $this->isHidden(), 'use_container' => false, 'add_variables' => true, 'add_widgets' => true, 'no_display' => false, 'encode_directives' => true, 'baseStaticUrl' => $this->_assetRepo->getStaticViewFileContext()->getBaseUrl(), 'baseStaticDefaultUrl' => str_replace('index.php/', '', $this->_backendUrl->getBaseUrl()) . $this->filesystem->getUri(DirectoryList::STATIC_VIEW) . '/', 'directives_url' => $this->_backendUrl->getUrl('cms/wysiwyg/directive'), 'popup_css' => $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/dialog.css'), 'content_css' => $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/advanced/skins/default/content.css'), 'width' => '100%', 'height' => '500px', 'plugins' => []]);
     $config->setData('directives_url_quoted', preg_quote($config->getData('directives_url')));
     if ($this->_authorization->isAllowed('Magento_Cms::media_gallery')) {
         $config->addData(['add_images' => true, 'files_browser_window_url' => $this->_backendUrl->getUrl('cms/wysiwyg_images/index'), 'files_browser_window_width' => $this->_windowSize['width'], 'files_browser_window_height' => $this->_windowSize['height']]);
     }
     if (is_array($data)) {
         $config->addData($data);
     }
     if ($config->getData('add_variables')) {
         $settings = $this->_variableConfig->getWysiwygPluginSettings($config);
         $config->addData($settings);
     }
     if ($config->getData('add_widgets')) {
         $settings = $this->_widgetConfig->getPluginSettings($config);
         $config->addData($settings);
     }
     return $config;
 }
Beispiel #9
0
 /**
  * Return files
  *
  * @param string $path Parent directory path
  * @param string $type Type of storage, e.g. image, media etc.
  * @return \Magento\Framework\Data\Collection\Filesystem
  */
 public function getFilesCollection($path, $type = null)
 {
     if ($this->_coreFileStorageDb->checkDbUsage()) {
         $files = $this->_storageDatabaseFactory->create()->getDirectoryFiles($path);
         /** @var \Magento\MediaStorage\Model\File\Storage\File $fileStorageModel */
         $fileStorageModel = $this->_storageFileFactory->create();
         foreach ($files as $file) {
             $fileStorageModel->saveFile($file);
         }
     }
     $collection = $this->getCollection($path)->setCollectDirs(false)->setCollectFiles(true)->setCollectRecursively(false)->setOrder('mtime', \Magento\Framework\Data\Collection::SORT_ORDER_ASC);
     // Add files extension filter
     if ($allowed = $this->getAllowedExtensions($type)) {
         $collection->setFilesFilter('/\\.(' . implode('|', $allowed) . ')$/i');
     }
     // prepare items
     foreach ($collection as $item) {
         $item->setId($this->_cmsWysiwygImages->idEncode($item->getBasename()));
         $item->setName($item->getBasename());
         $item->setShortName($this->_cmsWysiwygImages->getShortFilename($item->getBasename()));
         $item->setUrl($this->_cmsWysiwygImages->getCurrentUrl() . $item->getBasename());
         if ($this->isImage($item->getBasename())) {
             $thumbUrl = $this->getThumbnailUrl($item->getFilename(), true);
             // generate thumbnail "on the fly" if it does not exists
             if (!$thumbUrl) {
                 $thumbUrl = $this->_backendUrl->getUrl('cms/*/thumbnail', ['file' => $item->getId()]);
             }
             $size = @getimagesize($item->getFilename());
             if (is_array($size)) {
                 $item->setWidth($size[0]);
                 $item->setHeight($size[1]);
             }
         } else {
             $thumbUrl = $this->_assetRepo->getUrl(self::THUMB_PLACEHOLDER_PATH_SUFFIX);
         }
         $item->setThumbUrl($thumbUrl);
     }
     return $collection;
 }
Beispiel #10
0
 /**
  * Full url to new image
  *
  * @return string
  */
 public function __toString()
 {
     try {
         if ($this->getImageFile()) {
             $this->getModel()->setBaseFile($this->getImageFile());
         } else {
             $this->getModel()->setBaseFile($this->getItem()->getData($this->getModel()->getDestinationSubDir()));
         }
         if ($this->getModel()->isCached()) {
             return $this->getModel()->getUrl();
         } else {
             if ($this->scheduleResize) {
                 $this->getModel()->resize();
             }
             if ($this->scheduleCrop) {
                 $this->getModel()->crop();
             }
             $url = $this->getModel()->saveFile()->getUrl();
         }
     } catch (\Exception $e) {
         $url = $this->assetRepo->getUrl($this->getPlaceholder());
     }
     return $url;
 }
 /**
  * Gather information to be sent to javascript method renderer
  *
  * @return array
  */
 public function getConfig()
 {
     return $this->methodInstance->isAvailable() ? ['payment' => [$this->methodCode => ['bannerUrl' => $this->_scopeConfig->getValue('payment/mercadopago_custom/banner_checkout'), 'country' => strtoupper($this->_scopeConfig->getValue('payment/mercadopago/country', 'default', $this->_storeManager->getStore()->getId())), 'grand_total' => $this->_checkoutSession->getQuote()->getGrandTotal(), 'base_url' => $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK), 'success_url' => $this->methodInstance->getConfigData('order_place_redirect_url'), 'logEnabled' => $this->_scopeConfig->getValue('payment/mercadopago/logs', 'default', $this->_storeManager->getStore()->getId()), 'discount_coupon' => $this->_scopeConfig->isSetFlag('payment/mercadopago_custom/coupon_mercadopago', 'default', $this->_storeManager->getStore()->getId()), 'route' => $this->_request->getRouteName(), 'public_key' => $this->_scopeConfig->getValue('payment/mercadopago_custom/public_key'), 'customer' => $this->methodInstance->getCustomerAndCards(), 'loading_gif' => $this->_assetRepo->getUrl('MercadoPago_Core::images/loading.gif'), 'text-currency' => __('$'), 'text-choice' => __('Choice'), 'default-issuer' => __('Default issuer'), 'text-installment' => __('Enter the card number'), 'logoUrl' => $this->_assetRepo->getUrl("MercadoPago_Core::images/mp_logo.png")]]] : [];
 }
 /**
  * @return string
  */
 public function getRemoveLinkHtml()
 {
     $src = $this->_assetRepo->getUrl('images/rule_component_remove.gif');
     $html = ' <span class="rule-param"><a href="javascript:void(0)" class="rule-param-remove" title="' . __('Remove') . '"><img src="' . $src . '"  alt="" class="v-middle" /></a></span>';
     return $html;
 }
Beispiel #13
0
 /**
  * Return default themes preview image url
  *
  * @return string
  */
 public function getPreviewImageDefaultUrl()
 {
     return $this->assetRepo->getUrl(self::DEFAULT_PREVIEW_IMAGE);
 }
Beispiel #14
0
 /**
  * Absolute url to file
  *
  * @return string
  */
 public function getUrl()
 {
     if ($this->newFile === true) {
         $url = $this->assetRepo->getUrl("Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg");
     } else {
         $baseDir = $this->baseMediaPath;
         $path = str_replace($baseDir, '', $this->newFile);
         $url = $this->baseMediaUrl . $path;
     }
     return $url;
 }
Beispiel #15
0
 /**
  * @return string
  */
 public function getUrl()
 {
     if ($this->_newFile === true) {
         $url = $this->_assetRepo->getUrl("Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg");
     } else {
         $url = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $this->_newFile;
     }
     return $url;
 }
 /**
  * @return array
  */
 public function getConfig()
 {
     return $this->methodInstance->isAvailable() ? ['payment' => [$this->methodCode => ['bannerUrl' => $this->methodInstance->getConfigData('banner_checkout'), 'options' => $this->methodInstance->getTicketsOptions(), 'country' => strtoupper($this->_scopeConfig->getValue('payment/mercadopago/country')), 'grand_total' => $this->_checkoutSession->getQuote()->getGrandTotal(), 'success_url' => $this->methodInstance->getConfigData('order_place_redirect_url'), 'route' => $this->_request->getRouteName(), 'base_url' => $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_LINK), 'discount_coupon' => $this->_scopeConfig->getValue('payment/mercadopago_customticket/coupon_mercadopago'), 'loading_gif' => $this->_assetRepo->getUrl('MercadoPago_Core::images/loading.gif'), 'logEnabled' => $this->_scopeConfig->getValue('payment/mercadopago/logs'), 'logoUrl' => $this->_assetRepo->getUrl("MercadoPago_Core::images/mp_logo.png")]]] : [];
 }
Beispiel #17
0
 /**
  * Return url to wysiwyg plugin
  *
  * @return string
  * @codeCoverageIgnore
  */
 public function getWysiwygJsPluginSrc()
 {
     $editorPluginJs = 'mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js';
     return $this->_assetRepo->getUrl($editorPluginJs);
 }
Beispiel #18
0
 /**
  * Get PayFast "mark" image URL
  * may be his can be place in the config xml
  *
  * @return string
  */
 public function getPaymentMarkImageUrl()
 {
     return $this->_assetRepo->getUrl('Payfast_Payfast::images/logo.png');
 }
Beispiel #19
0
 /**
  * Return config settings for widgets insertion plugin based on editor element config
  *
  * @param \Magento\Framework\DataObject $config
  * @return array
  */
 public function getPluginSettings($config)
 {
     $url = $this->_assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js');
     $settings = ['widget_plugin_src' => $url, 'widget_placeholders' => $this->_widgetFactory->create()->getPlaceholderImageUrls(), 'widget_window_url' => $this->getWidgetWindowUrl($config)];
     return $settings;
 }
Beispiel #20
0
 /**
  * @param \Magento\Framework\View\Element\Template $block
  * @return \Magento\Framework\View\Element\Template
  */
 public function assignBlockVariables(\Magento\Framework\View\Element\Template $block)
 {
     $block->assign(['htmlId' => $this->_escaper->escapeHtml($this->getHtmlId()), 'fileMaxSize' => $this->maxFileSize, 'uploadUrl' => $this->_escaper->escapeHtml($this->_getUploadUrl()), 'spacerImage' => $this->assetRepo->getUrl('images/spacer.gif'), 'imagePlaceholderText' => __('Click here or drag and drop to add images.'), 'deleteImageText' => __('Delete image'), 'makeBaseText' => __('Make Base'), 'hiddenText' => __('Hidden'), 'imageManagementText' => __('Images and Videos')]);
     return $block;
 }
Beispiel #21
0
 /**
  * Return URL for skin images placeholder
  *
  * @return string
  */
 public function getSkinImagePlaceholderUrl()
 {
     return $this->_assetRepo->getUrl('Magento_Cms::images/wysiwyg_skin_image.png');
 }
 /**
  * Return image url
  *
  * @return string|null
  */
 public function getImageUrl($imageName)
 {
     $url = $this->_assetRepo->getUrl("MercadoPago_Core::images/" . $imageName);
     return $url;
 }