Ejemplo n.º 1
0
    require_once JPATH_COMPONENT . '/controller.php';
    $controller = new ScriptMergeController();
    // Perform the Request task
    $controller->execute(JRequest::getCmd('task'));
    $controller->redirect();
    return;
}
// Initialize files
if (!empty($files)) {
    $files = base64_decode($files);
    $files = explode(',', $files);
}
$buffer = null;
if (!empty($files)) {
    // Instantiate the helper
    $helper = new ScriptMergeHelper();
    foreach ($files as $file) {
        // Basic security check
        if (!preg_match('/\\.(css|js)$/', $file)) {
            continue;
        }
        // CSS-code
        if ($type == 'css') {
            header('Content-Type: text/css');
            $buffer .= $helper->getCssContent($file);
            // JS-code
        } else {
            header('Content-Type: application/javascript');
            $buffer .= $helper->getJsContent($file);
        }
    }
Ejemplo 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');
// Require the helper
require_once JPATH_SITE . '/components/com_scriptmerge/helpers/helper.php';
$helper = new ScriptMergeHelper();
// Test
if (JRequest::getInt('test', 0) == 1) {
    require_once 'test.php';
}
// Read the files parameter
$files = JRequest::getString('files');
if (!empty($files)) {
    $files = $helper->decodeList($files);
    $buffer = null;
    foreach ($files as $file) {
        if ($type == 'css') {
            if (!preg_match('/\\.css$/', $file)) {
                continue;
            }
            $buffer .= $helper->getCssContent($file);
        } else {
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
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;