/** * Minimize css files * * @return void */ public function minimize($id_theme, $name) { $msg = null; // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'themes', $id_theme, 4); if (is_null($msg)) { $qs = X4Route_core::get_query_string(); // do action $res = 1; // get the templates in the theme $mod = new Theme_model(); // CSS section $path = PATH . 'themes/' . $name . '/css/'; $items = $mod->get_css($id_theme); foreach ($items as $i) { if (file_exists($path . $i->css . '.css')) { $txt = file_get_contents($path . $i->css . '.css'); $txt = $mod->compress_css($txt); $chk = file_put_contents($path . $i->css . '.min.css', $txt); if (!$chk) { $res = 0; } } } // JS section X4Core_core::auto_load('jshrink_library'); $path = PATH . 'themes/' . $name . '/js/'; $items = $mod->get_js($id_theme); foreach ($items as $i) { if (file_exists($path . $i->js . '.js')) { $txt = file_get_contents($path . $i->js . '.js'); $txt = Minifier::minify($txt, array('flaggedComments' => false)); $chk = file_put_contents($path . $i->js . '.min.js', $txt); if (!$chk) { $res = 0; } } } $result = array(0, $res); // set message $this->dict->get_words(); $msg = AdmUtils_helper::set_msg($result); // set update if ($result[1]) { $msg->update[] = array('element' => $qs['div'], 'url' => urldecode($qs['url']), 'title' => null); } } $this->response($msg); }