Exemplo n.º 1
0
 /**
  * Method to translate images into data URIs
  *
  * @param string $text
  *
  * @return string
  */
 private function parseImages($text = null)
 {
     if ($this->params->get('data_uris', 0) != 1) {
         return $text;
     }
     if (preg_match_all('/src=([\'\\"]{1})([^\'\\"]+)([\'\\"]{1})/i', $text, $matches)) {
         foreach ($matches[2] as $index => $match) {
             $match = preg_replace('/([\'\\"\\ ]+)/', '', $match);
             $path = ScriptMergeHelper::getFilePath($match);
             $content = ScriptMergeHelper::getImageUrl($path);
             if (!empty($content)) {
                 $text = str_replace($matches[0][$index], 'src=' . $content, $text);
             }
         }
     }
     if (preg_match_all('/url\\(([a-zA-Z0-9\\.\\-\\_\\/\\ \' \\"]+)\\)/i', $text, $matches)) {
         foreach ($matches[1] as $index => $match) {
             $match = preg_replace('/([\'\\"\\ ]+)/', '', $match);
             $path = ScriptMergeHelper::getFilePath($match);
             $content = ScriptMergeHelper::getImageUrl($path);
             if (!empty($content)) {
                 $text = str_replace($matches[0][$index], 'url(' . $content . ')', $text);
             }
         }
     }
     if (preg_match_all('/url\\(([a-zA-Z0-9\\.\\-\\_\\/\\ \' \\"]+)\\)/i', $text, $matches)) {
         foreach ($matches[1] as $index => $match) {
             $match = preg_replace('/([\'\\"\\ ]+)/', '', $match);
             $path = ScriptMergeHelper::getFilePath($match);
             $content = ScriptMergeHelper::getImageUrl($path);
             if (!empty($content)) {
                 $text = str_replace($matches[0][$index], 'url(' . $content . ')', $text);
             }
         }
     }
     return $text;
 }
Exemplo n.º 2
0
<?php

/**
 * Joomla! System plugin - ScriptMerge
 *
 * @author Yireo (info@yireo.com)
 * @copyright Copyright 2015
 * @license GNU Public License
 * @link http://www.yireo.com
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
$strings = array('templates/system/css/system.css' => null, '/media/system/js/mootools-core.js' => null, '../../../../media/system/css/system.css' => JPATH_ADMINISTRATOR . '/templates/system/css/system.css', '../images/calendar.png' => JPATH_ADMINISTRATOR . '/templates/system/css/', '../images/none.png' => JPATH_ADMINISTRATOR . '/templates/system/css/');
foreach ($strings as $file => $basepath) {
    $path = ScriptMergeHelper::getFilePath($file, $basepath);
    echo "{$file} = {$path}\n";
    echo is_file($path) ? 'OK' : 'FAIL';
    echo " = " . ScriptMergeHelper::getFileUrl($path);
    echo "\n\n";
}
exit;