Download js file by path and store result in tmp directory and return new href value
@param \stdClass $item
@param boolean   $minify
@return string
332358
private function _downloadFileToTmpAndGetNewHref ($item, $minify = FALSE) {
		$path = $item->path;
		$tmpFileFullPath = $this->getTmpDir() . '/external_js_' . md5($path) . '.js';
		if (self::$fileRendering) {
			if (file_exists($tmpFileFullPath)) {
				$cacheFileTime = filemtime($tmpFileFullPath);
			} else {
				$cacheFileTime = 0;
			}
			if (time() > $cacheFileTime + self::EXTERNAL_MIN_CACHE_TIME) {
				while (TRUE) {
					$newPath = $this->_getPossiblyRedirectedPath($path);
					if ($newPath === $path) {
						break;
					} else {
						$path = $newPath;
					}
				}
				$fr = fopen($path, 'r');
				$fileContent = '';
				$bufferLength = 102400; // 100 KB
				$buffer = '';
				while ($buffer = fread($fr, $bufferLength)) {
					$fileContent .= $buffer;
				}
				fclose($fr);
				if ($minify) {
					$fileContent = $this->_minify($fileContent, $path);
				}
				$this->saveFileContent($tmpFileFullPath, $fileContent);
				$this->log("External js file downloaded ('$tmpFileFullPath').", 'debug');
			}
		}
		$tmpPath = substr($tmpFileFullPath, strlen($this->getAppRoot()));
		return $tmpPath;
	}
280667
public function renderItem( $item ) {

        $label      = null;
        $url        = isset( $item[ 'url' ] ) ? $item[ 'url' ] : null;
		$urlOptions	= isset( $item[ 'urlOptions' ] ) ? $item[ 'urlOptions' ] : null;
        $options    = [];

		// Check whether label is required
		if( $this->label ) {

	        if( !isset( $item[ 'label' ] ) ) {

	            throw new InvalidConfigException( "The 'label' option is required." );
	        }

	        $label = $item[ 'label' ];
		}

		// Check whether icon is required
		if( $this->icon ) {

	        if( !isset( $item[ 'icon' ] ) ) {

	            throw new InvalidConfigException( "The 'icon' option is required." );
	        }

			$icon	= Html::tag( 'i', null, [ 'class' =>  $item[ 'icon' ] ] );
			$label	= "<span class='wrap-icon'>$icon</span><span class='wrap-text'>$label</span>";
		}

		if( isset( $item[ 'options' ] ) ) {

			$options = $item[ 'options' ];
		}

		if( isset( $url ) ) {

			$link = Html::a( $label, $url, $urlOptions );
		}

		// Custom Links
		if( isset( $options[ 'action' ] ) ) {

			$urlOptions[ 'link' ] = $url;

			$link = Html::tag( 'span', $label, $urlOptions );
		}

		// Custom HTML
		if( isset( $options[ 'html' ] ) ) {

			$link = $options[ 'html' ];

			unset( $options[ 'html' ] );
		}

        return Html::tag( 'li', $link, $options );
    }
586022
function slash_item($item)
	{
		if ( ! isset($this->config[$item]))
		{
			return FALSE;
		}
		if( trim($this->config[$item]) == '')
		{
			return '';
		}

		return rtrim($this->config[$item], '/').'/';
	}
221946
public function getAction($item)
    {
        $options = [
            'query' => [
                'item'      => $this->getItemId($item),
                'processor' => $this->getId(),
            ],
        ];
        if ($this->isLinkDialog()) {
            $options['attributes']['class'][] = 'use-ajax';
            $options['attributes']['class'][] = 'minidialog';
            $options['query']['minidialog'] = 1;
            $options['query'] += drupal_get_destination();
        }

        return new Action(
            $this->getLinkTitle(),
            'admin/calista/action-process',
            $options,
            $this->getLinkIcon(),
            $this->getLinkPriority(),
            $this->isLinkPrimary(),
            true,
            false,
            $this->getLinkGroup()
        );
    }
855358
public function getCssContent(string $fileName, bool $minify): string
    {
        $content = file_get_contents($fileName);

        if ($content === false) {
            throw new RuntimeException(sprintf('File could be read: %s', $fileName));
        }

        if ($minify === true) {
            $compressor = new CssMinifier();
            $content = $compressor->run($content);
        }

        return $content;
    }
849713
public function minify()
    {
        $cleaned_stack = $this->cleanStack($this->get(), 'path');
        if (!empty($cleaned_stack)) {
            foreach ($cleaned_stack as $i=>$item) {
                if (isset($item['minified']) && true===$item['minified']) {
                    unset($cleaned_stack[$i]);
                }
            }
        }
        if (!empty($cleaned_stack)) {
            $this->addMinified(
                $this->minifyStack($this->extractFromStack($cleaned_stack, 'path'))
            );
        }
        return $this;
    }
985525
public function create(LibraryType $library, DirectoryItem $item): bool
    {
        // do not allow empty paths
        if (empty($item->path) || empty($item->name)) {
            return false;
        }

        $uri = sprintf(
            '%s/repos/%s/file/?p=%s',
            $this->clipUri($this->client->getConfig('base_uri')),
            $library->id,
            $this->urlEncodePath($item->path . $item->name)
        );

        $response = $this->client->request(
            'POST',
            $uri,
            [
                'headers'   => ['Accept' => 'application/json'],
                'multipart' => [
                    [
                        'name'     => 'operation',
                        'contents' => 'create',
                    ],
                ],
            ]
        );

        return $response->getStatusCode() === 201;
    }
1225997
public static function getItemIconO( StaticItemDto $item, array $attributes = [] ): Html
	{
		return self::getItemIcon($item->id, $attributes);
	}
657028
public static function cdn($res, $min = '') {
        static $static_url = false;
        if ($static_url === false) {
            $static_url = App::cfg('cdn_base');
            if ($static_url) {
                $static_url = trailingslashit($static_url . WWWROOT_DIR);
            } else {
                $static_url = WWWROOT_DIR;
            }
        }
        if (preg_match('#^(/|https?://).+$#', $res)) {
            return $res;
        }
        $url = ltrim($res, '/');

        return $static_url . $url . '?_ver=' . BUILD_NUMBER;
    }
486444
public function column_file( $item ) {
		$html = '<div class="export-file">';
		$html .= $this->getIcon( $item['file'] );
		$html .= '<div class="export-file-name">' . esc_html( $item['file'] ) . '</div>';
		$html .= '</div>';

		$delete_url = sprintf( '/admin.php?page=%s&action=%s&ID=%s', $_REQUEST['page'], 'delete', $item['ID'] );
		$delete_url = get_admin_url( get_current_blog_id(), $delete_url );
		$delete_url = esc_url( add_query_arg( '_wpnonce', wp_create_nonce( 'bulk-files' ), $delete_url ) );
		$onclick = 'onclick="if ( !confirm(\'' . esc_attr( __( 'Are you sure you want to delete this export file?', 'pressbooks' ) ) . '\') ) { return false }"';
		$actions['delete'] = sprintf(
			'<a href="%s" aria-label="%s" ' . $onclick . '>%s</a>',
			$delete_url,
			/* translators: %s: file */
			esc_attr( sprintf( __( 'Delete &#8220;%s&#8221;' ), $item['file'] ) ),
			_x( 'Delete', 'verb' )
		);

		$download_url = get_admin_url( get_current_blog_id(), "/admin.php?page=pb_export&download_export_file={$item['file']}" );
		$actions['download'] = sprintf(
			'<a href="%s" aria-label="%s" >%s</a>',
			$download_url,
			/* translators: %s: file */
			esc_attr( sprintf( __( 'Download &#8220;%s&#8221;' ), $item['file'] ) ),
			_x( 'Download', 'verb' )
		);

		$html .= $this->row_actions( $actions );

		return $html;
	}
909050
protected function fixPaths(Item $item)
    {
        $url = new Url($item->getSource());
        $item->setIntro($this->getFixedText($item->getIntro(), $url->getFullHost()));
        $item->setContent($this->getFixedText($item->getContent(), $url->getFullHost()));

        return $item;
    }
1292474
protected function dumpFile($dir, $content)
    {
        $this->checkTempdir($dir);
        $tmpFile = tempnam($dir, 'cc_');
        if (!$tmpFile) {
            throw new Minify_ClosureCompiler_Exception('Could not create temp file in "' . $dir . '".');
        }
        file_put_contents($tmpFile, $content);

        return $tmpFile;
    }
1039143
protected function getJsContent(string $file, bool $minify): string
    {
        $content = file_get_contents($file);

        if ($content === false) {
            throw new RuntimeException(sprintf('File could be read: %s', $file));
        }

        if ($minify) {
            $content = JSMin::minify($content);
        }

        return $content;
    }
1321743
public function minify($path = null)
    {
        $content = $this->execute($path);

        // save to path
        if ($path !== null) {
            $this->save($content, $path);
        }

        return $content;
    }
298299
protected function getItemLine(stdClass $item)
    {
        $result = array();
        $this->addPropertySource('item', $item);

        $this->addProductInfo($result);

        $productPriceEx = (float) $item->product_discountedPriceWithoutTax;
        $productPriceInc = (float) $item->product_final_price;
        $productVat = (float) $item->product_tax;

        $calcRule = $this->getCalcRule('VatTax', $item->virtuemart_order_item_id);
        if (!empty($calcRule->calc_value)) {
            $vatInfo = array(
                Tag::VatRate => (float) $calcRule->calc_value,
                Meta::VatRateSource => static::VatRateSource_Exact,
                Meta::VatClassId => $calcRule->virtuemart_calc_id,
                Meta::VatClassName => $calcRule->calc_rule_name,
            );
        } else {
            $vatInfo = $this->getVatRangeTags($productVat, $productPriceEx, $this->precision, $this->precision);
        }

        // Check for cost price and margin scheme.
        if (!empty($line['costPrice']) && $this->allowMarginScheme()) {
            // Margin scheme:
            // - Do not put VAT on invoice: send price incl VAT as unitprice.
            // - But still send the VAT rate to Acumulus.
            $result[Tag::UnitPrice] = $productPriceInc;
        } else {
            $result += array(
                Tag::UnitPrice => $productPriceEx,
                Meta::UnitPriceInc => $productPriceInc,
                Meta::VatAmount => $productVat,
            );
        }
        $result[Tag::Quantity] = $item->product_quantity;
        $result += $vatInfo;

        // Add variant info.
        $children = $this->getVariantLines($item, $result[Tag::Quantity], $vatInfo);
        if (!empty($children)) {
            $result[Meta::ChildrenLines] = $children;
        }

        $this->removePropertySource('item');

        return $result;
    }
127787
public function javascriptMinify($file, $type = 'file')
    {
        $file = $this->getFile($file, $type);
        $file = preg_replace(["/\/\/(.*\s+)/", "/;+\}/"], ['', '}'], $file);
        $file = $this->cleanSpaces($file);
        $file = $this->removeComments($file);

        return $file;
    }
303982
private function _renderItemsTogether ($actualGroupName = '', $items = [], $indent = 0, $minify = FALSE) {
		// some configurations is not possible to render together and minimized
		list($itemsToRenderMinimized, $itemsToRenderSeparately) = $this->filterItemsForNotPossibleMinifiedAndPossibleMinifiedItems($items);

		$indentStr = $this->getIndentString($indent);
		$resultItems = [];
		if (self::$fileRendering) $resultItems[] = '<!-- css group begin: ' . $actualGroupName . ' -->';

		// process array with groups, which are not possible to minimize
		foreach ($itemsToRenderSeparately as & $itemsToRender) {
			$resultItems[] = $this->_renderItemsTogetherAsGroup($itemsToRender, $minify);
		}

		// process array with groups to minimize
		foreach ($itemsToRenderMinimized as & $itemsToRender) {
			$resultItems[] = $this->_renderItemsTogetherAsGroup($itemsToRender, $minify);
		}

		if (self::$fileRendering) $resultItems[] = '<!-- css group end: ' . $actualGroupName . ' -->';

		return $indentStr . implode(PHP_EOL . $indentStr, $resultItems);
	}