Exemplo n.º 1
0
         } else {
             $excluded[$key]['html'][] = $v;
         }
     }
 }
 // Main options for MinifyX
 $scriptProperties = array('cacheFolder' => $modx->getOption('minifyx_cacheFolder', null, '/assets/components/minifyx/cache/', true), 'forceUpdate' => $modx->getOption('minifyx_forceUpdate', null, false, true), 'minifyJs' => $modx->getOption('minifyx_minifyJs', null, false, true), 'minifyCss' => $modx->getOption('minifyx_minifyCss', null, false, true), 'jsFilename' => $modx->getOption('minifyx_jsFilename', null, 'all', true), 'cssFilename' => $modx->getOption('minifyx_cssFilename', null, 'all', true));
 /** @var MinifyX $MinifyX */
 $MinifyX = new MinifyX($modx, $scriptProperties);
 if (!$MinifyX->prepareCacheFolder()) {
     $this->modx->log(modX::LOG_LEVEL_ERROR, '[MinifyX] Could not create cache dir "' . $scriptProperties['cacheFolder'] . '"');
     return;
 }
 $cacheFolderUrl = MODX_BASE_URL . str_replace(MODX_BASE_PATH, '', $MinifyX->config['cacheFolder']);
 // Process raw scripts and styles
 $tmp_dir = $MinifyX->getTmpDir() . 'resources/' . $modx->resource->id . '/';
 foreach ($raw as $key => $value) {
     foreach ($value as $type => $rows) {
         $tmp = '';
         if ($type == 'css' && $modx->getOption('minifyx_processRawCss', null, false, true) || $type == 'js' && $modx->getOption('minifyx_processRawJs', null, false, true)) {
             $text = '';
             foreach ($rows as $text) {
                 $text = preg_replace('#^<(script|style).*?>#', '', $text);
                 $text = preg_replace('#</(script|style)>$#', '', $text);
                 $tmp .= $text;
             }
             if (!empty($tmp)) {
                 $file = sha1($tmp) . '.' . $type;
                 if (!file_exists($tmp_dir . $file)) {
                     if (!file_exists($tmp_dir)) {
                         $MinifyX->makeDir($tmp_dir);