コード例 #1
0
 /**
  * compiles specified tpl file and execution result in Context into resultant content
  * @param string $tpl_path path of the directory containing target template file
  * @param string $tpl_filename target template file's name
  * @param string $tpl_file if specified use it as template file's full path
  * @return string Returns compiled result in case of success, NULL otherwise
  */
 public function compile($tpl_path, $tpl_filename, $tpl_file = '')
 {
     // store the starting time for debug information
     $start = microtime(true);
     // initiation
     $this->init($tpl_path, $tpl_filename, $tpl_file);
     // if target file does not exist exit
     if (!$this->file || !file_exists($this->file)) {
         $error_message = "Template not found: {$tpl_path}{$tpl_filename}" . ($tpl_file ? " ({$tpl_file})" : '');
         trigger_error($error_message, \E_USER_WARNING);
         return escape($error_message);
     }
     // for backward compatibility
     if (is_null(self::$rootTpl)) {
         self::$rootTpl = $this->file;
     }
     $latest_mtime = max(filemtime($this->file), $this->handler_mtime);
     // make compiled file
     if (!file_exists($this->compiled_file) || filemtime($this->compiled_file) < $latest_mtime) {
         $buff = $this->parse();
         if (Rhymix\Framework\Storage::write($this->compiled_file, $buff) === false) {
             $tmpfilename = tempnam(sys_get_temp_dir(), 'rx-compiled');
             if ($tmpfilename === false || Rhymix\Framework\Storage::write($tmpfilename, $buff) === false) {
                 return 'Fatal Error : Cannot create temporary file. Please check permissions.';
             }
             $this->compiled_file = $tmpfilename;
         }
     }
     Rhymix\Framework\Debug::addFilenameAlias($this->file, $this->compiled_file);
     $output = $this->_fetch($this->compiled_file);
     // delete tmpfile
     if (isset($tmpfilename)) {
         Rhymix\Framework\Storage::delete($tmpfilename);
     }
     if ($__templatehandler_root_tpl == $this->file) {
         $__templatehandler_root_tpl = null;
     }
     // store the ending time for debug information
     $GLOBALS['__template_elapsed__'] += microtime(true) - $start;
     return $output;
 }
コード例 #2
0
ファイル: Validator.class.php プロジェクト: rhymix/rhymix
 /**
  * Returns compiled javascript file path. The path begins from XE root directory.
  * @return string Compiled JavaScript file path
  */
 function getJsPath()
 {
     if (!$this->_cache_dir) {
         return FALSE;
     }
     $dir = $this->_cache_dir . '/ruleset';
     if (!is_dir($dir) && !mkdir($dir)) {
         return FALSE;
     }
     if (!$this->_xml_path) {
         return FALSE;
     }
     // current language
     $lang_type = class_exists('Context', false) ? Context::getLangType() : 'en';
     // check the file
     $filepath = $dir . '/' . md5($this->_version . ' ' . $this->_xml_path) . ".{$lang_type}.js";
     if (is_readable($filepath) && filemtime($filepath) > filemtime($this->_xml_path)) {
         return $filepath;
     }
     $content = $this->_compile2js();
     if ($content === FALSE) {
         return FALSE;
     }
     Rhymix\Framework\Storage::write($filepath, $content);
     return $filepath;
 }
コード例 #3
0
 protected function _saveDefaultImage($deleteIcon = false)
 {
     $image_filepath = 'files/attach/xeicon/';
     $site_info = Context::get('site_module_info');
     if ($site_info->site_srl) {
         $image_filepath .= $site_info->site_srl . '/';
     }
     if ($deleteIcon) {
         $info = Rhymix\Framework\Storage::readPHPData($image_filepath . 'default_image.php');
         if ($info['filename']) {
             Rhymix\Framework\Storage::delete(\RX_BASEDIR . $info['filename']);
         }
         Rhymix\Framework\Storage::delete($image_filepath . 'default_image.php');
         return;
     }
     $tmpicon_filepath = \RX_BASEDIR . $image_filepath . 'tmp/default_image.png';
     if (file_exists($tmpicon_filepath)) {
         list($width, $height, $type) = @getimagesize($tmpicon_filepath);
         switch ($type) {
             case 'image/gif':
                 $target_filename = $image_filepath . 'default_image.gif';
                 break;
             case 'image/jpeg':
                 $target_filename = $image_filepath . 'default_image.jpg';
                 break;
             case 'image/png':
             default:
                 $target_filename = $image_filepath . 'default_image.png';
         }
         Rhymix\Framework\Storage::move($tmpicon_filepath, \RX_BASEDIR . $target_filename);
         Rhymix\Framework\Storage::writePHPData(\RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site . 'default_image.php', array('filename' => $target_filename, 'width' => $width, 'height' => $height));
     }
 }
コード例 #4
0
ファイル: file.controller.php プロジェクト: rhymix/rhymix
 /**
  * Add an attachement
  *
  * <pre>
  * This method call trigger 'file.insertFile'.
  *
  * Before trigger object contains:
  * - module_srl
  * - upload_target_srl
  *
  * After trigger object contains:
  * - file_srl
  * - upload_target_srl
  * - module_srl
  * - direct_download
  * - source_filename
  * - uploaded_filename
  * - donwload_count
  * - file_size
  * - comment
  * - member_srl
  * - sid
  * </pre>
  *
  * @param object $file_info PHP file information array
  * @param int $module_srl Sequence of module to upload file
  * @param int $upload_target_srl Sequence of target to upload file
  * @param int $download_count Initial download count
  * @param bool $manual_insert If set true, pass validation check
  * @return Object
  */
 function insertFile($file_info, $module_srl, $upload_target_srl, $download_count = 0, $manual_insert = false)
 {
     // Call a trigger (before)
     $trigger_obj = new stdClass();
     $trigger_obj->module_srl = $module_srl;
     $trigger_obj->upload_target_srl = $upload_target_srl;
     $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj);
     if (!$output->toBool()) {
         return $output;
     }
     // A workaround for Firefox upload bug
     if (preg_match('/^=\\?UTF-8\\?B\\?(.+)\\?=$/i', $file_info['name'], $match)) {
         $file_info['name'] = base64_decode(strtr($match[1], ':', '/'));
     }
     if (!$manual_insert) {
         // Get the file configurations
         $logged_info = Context::get('logged_info');
         if ($logged_info->is_admin != 'Y') {
             $oFileModel = getModel('file');
             $config = $oFileModel->getFileConfig($module_srl);
             // check file type
             if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') {
                 $filetypes = explode(';', $config->allowed_filetypes);
                 $ext = array();
                 foreach ($filetypes as $item) {
                     $item = explode('.', $item);
                     $ext[] = strtolower($item[1]);
                 }
                 $uploaded_ext = explode('.', $file_info['name']);
                 $uploaded_ext = strtolower(array_pop($uploaded_ext));
                 if (!in_array($uploaded_ext, $ext)) {
                     return $this->stop('msg_not_allowed_filetype');
                 }
             }
             $allowed_filesize = $config->allowed_filesize * 1024 * 1024;
             $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024;
             // An error appears if file size exceeds a limit
             if ($allowed_filesize < filesize($file_info['tmp_name'])) {
                 return new Object(-1, 'msg_exceeds_limit_size');
             }
             // Get total file size of all attachements (from DB)
             $size_args = new stdClass();
             $size_args->upload_target_srl = $upload_target_srl;
             $output = executeQuery('file.getAttachedFileSize', $size_args);
             $attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']);
             if ($attached_size > $allowed_attach_size) {
                 return new Object(-1, 'msg_exceeds_limit_size');
             }
         }
     }
     // Sanitize filename
     $file_info['name'] = Rhymix\Framework\Filters\FilenameFilter::clean($file_info['name']);
     // Set upload path by checking if the attachement is an image or other kinds of file
     if (preg_match("/\\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)\$/i", $file_info['name'])) {
         $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
         // special character to '_'
         // change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter
         $ext = substr(strrchr($file_info['name'], '.'), 1);
         //$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']);
         $_filename = Rhymix\Framework\Security::getRandom(32, 'hex') . '.' . $ext;
         $filename = $path . $_filename;
         $idx = 1;
         while (file_exists($filename)) {
             $filename = $path . preg_replace('/\\.([a-z0-9]+)$/i', '_' . $idx . '.$1', $_filename);
             $idx++;
         }
         $direct_download = 'Y';
     } else {
         $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
         $filename = $path . Rhymix\Framework\Security::getRandom(32, 'hex');
         $direct_download = 'N';
     }
     // Create a directory
     if (!Rhymix\Framework\Storage::isDirectory($path) && !Rhymix\Framework\Storage::createDirectory($path)) {
         return new Object(-1, 'msg_not_permitted_create');
     }
     // Move the file
     if ($manual_insert) {
         @copy($file_info['tmp_name'], $filename);
         if (!file_exists($filename)) {
             $filename = $path . Rhymix\Framework\Security::getRandom(32, 'hex') . '.' . $ext;
             @copy($file_info['tmp_name'], $filename);
         }
     } else {
         if (!@move_uploaded_file($file_info['tmp_name'], $filename)) {
             $filename = $path . Rhymix\Framework\Security::getRandom(32, 'hex') . '.' . $ext;
             if (!@move_uploaded_file($file_info['tmp_name'], $filename)) {
                 return new Object(-1, 'msg_file_upload_error');
             }
         }
     }
     // Get member information
     $oMemberModel = getModel('member');
     $member_srl = $oMemberModel->getLoggedMemberSrl();
     // List file information
     $args = new stdClass();
     $args->file_srl = getNextSequence();
     $args->upload_target_srl = $upload_target_srl;
     $args->module_srl = $module_srl;
     $args->direct_download = $direct_download;
     $args->source_filename = $file_info['name'];
     $args->uploaded_filename = $filename;
     $args->download_count = $download_count;
     $args->file_size = @filesize($filename);
     $args->comment = NULL;
     $args->member_srl = $member_srl;
     $args->sid = Rhymix\Framework\Security::getRandom(32, 'hex');
     $output = executeQuery('file.insertFile', $args);
     if (!$output->toBool()) {
         return $output;
     }
     // Call a trigger (after)
     ModuleHandler::triggerCall('file.insertFile', 'after', $args);
     $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true;
     $output->add('file_srl', $args->file_srl);
     $output->add('file_size', $args->file_size);
     $output->add('sid', $args->sid);
     $output->add('direct_download', $args->direct_download);
     $output->add('source_filename', $args->source_filename);
     $output->add('upload_target_srl', $upload_target_srl);
     $output->add('uploaded_filename', $args->uploaded_filename);
     return $output;
 }
コード例 #5
0
ファイル: FileHandler.class.php プロジェクト: rhymix/rhymix
 /**
  * Check is writable dir
  *
  * @param string $path Target dir path
  * @return bool
  */
 public static function isWritableDir($path)
 {
     $path = self::getRealPath($path);
     return Rhymix\Framework\Storage::isDirectory($path) && Rhymix\Framework\Storage::isWritable($path);
 }
コード例 #6
0
ファイル: admin.admin.model.php プロジェクト: rhymix/rhymix
 function iconUrlCheck($iconname, $default_icon_name, $default)
 {
     if ($default) {
         return \RX_BASEURL . 'modules/admin/tpl/img/' . $default_icon_name;
     }
     $site_info = Context::get('site_module_info');
     if ($site_info->site_srl) {
         $virtual_site = $site_info->site_srl . '/';
     } else {
         $virtual_site = '';
     }
     $filename = 'files/attach/xeicon/' . $virtual_site . $iconname;
     if (Rhymix\Framework\Storage::exists(\RX_BASEDIR . $filename)) {
         return \RX_BASEURL . $filename . '?' . date('YmdHis', filemtime(\RX_BASEDIR . $filename));
     } else {
         return false;
     }
 }
コード例 #7
0
 /**
  * @brief Save the file of user-defined language code
  */
 function makeCacheDefinedLangCode($site_srl = 0)
 {
     $args = new stdClass();
     // Get the language file of the current site
     if (!$site_srl) {
         $site_module_info = Context::get('site_module_info');
         $args->site_srl = (int) $site_module_info->site_srl;
     } else {
         $args->site_srl = $site_srl;
     }
     $output = executeQueryArray('module.getLang', $args);
     if (!$output->toBool() || !$output->data) {
         return;
     }
     // Set the cache directory
     $cache_path = _XE_PATH_ . 'files/cache/lang_defined/';
     FileHandler::makeDir($cache_path);
     $langMap = array();
     foreach ($output->data as $val) {
         $langMap[$val->lang_code][$val->name] = $val->value;
     }
     $lang_supported = Context::loadLangSelected();
     $defaultLang = config('locale.default_lang');
     if (!is_array($langMap[$defaultLang])) {
         $langMap[$defaultLang] = array();
     }
     foreach ($lang_supported as $langCode => $langName) {
         if (!is_array($langMap[$langCode])) {
             $langMap[$langCode] = array();
         }
         $langMap[$langCode] += $langMap[$defaultLang];
         foreach ($lang_supported as $targetLangCode => $targetLangName) {
             if ($langCode == $targetLangCode || $langCode == $defaultLang) {
                 continue;
             }
             if (!is_array($langMap[$targetLangCode])) {
                 $langMap[$targetLangCode] = array();
             }
             $langMap[$langCode] += $langMap[$targetLangCode];
         }
         $buff = array("<?php if(!defined('__XE__')) exit();");
         foreach ($langMap[$langCode] as $code => $value) {
             $buff[] = sprintf('$lang[\'%s\'] = \'%s\';', $code, addcslashes($value, "'"));
         }
         if (!Rhymix\Framework\Storage::write(sprintf('%s/%d.%s.php', $cache_path, $args->site_srl, $langCode), join(PHP_EOL, $buff))) {
             return;
         }
     }
 }
コード例 #8
0
 /**
  * @brief Recalculate points based on the list/comment/attachment and registration information. Granted only once a first-time login score.
  */
 function procPointAdminReCal()
 {
     @set_time_limit(0);
     // Get per-module points information
     $oModuleModel = getModel('module');
     $config = $oModuleModel->getModuleConfig('point');
     $module_config = $oModuleModel->getModulePartConfigs('point');
     // A variable to store member's points
     $member = array();
     // Get member infomation
     $output = executeQueryArray('point.getMemberCount');
     if (!$output->toBool()) {
         return $output;
     }
     if ($output->data) {
         foreach ($output->data as $key => $val) {
             if (!$val->member_srl) {
                 continue;
             }
             $member[$val->member_srl] = 0;
         }
     }
     // Get post information
     $output = executeQueryArray('point.getDocumentPoint');
     if (!$output->toBool()) {
         return $output;
     }
     if ($output->data) {
         foreach ($output->data as $key => $val) {
             if ($module_config[$val->module_srl]['insert_document']) {
                 $insert_point = $module_config[$val->module_srl]['insert_document'];
             } else {
                 $insert_point = $config->insert_document;
             }
             if (!$val->member_srl) {
                 continue;
             }
             $point = $insert_point * $val->count;
             $member[$val->member_srl] += $point;
         }
     }
     $output = null;
     // Get comments information
     $output = executeQueryArray('point.getCommentPoint');
     if (!$output->toBool()) {
         return $output;
     }
     if ($output->data) {
         foreach ($output->data as $key => $val) {
             if ($module_config[$val->module_srl]['insert_comment']) {
                 $insert_point = $module_config[$val->module_srl]['insert_comment'];
             } else {
                 $insert_point = $config->insert_comment;
             }
             if (!$val->member_srl) {
                 continue;
             }
             $point = $insert_point * $val->count;
             $member[$val->member_srl] += $point;
         }
     }
     $output = null;
     // Get the attached files' information
     $output = executeQueryArray('point.getFilePoint');
     if (!$output->toBool()) {
         return $output;
     }
     if ($output->data) {
         foreach ($output->data as $key => $val) {
             if ($module_config[$val->module_srl]['upload_file']) {
                 $insert_point = $module_config[$val->module_srl]['upload_file'];
             } else {
                 $insert_point = $config->upload_file;
             }
             if (!$val->member_srl) {
                 continue;
             }
             $point = $insert_point * $val->count;
             $member[$val->member_srl] += $point;
         }
     }
     $output = null;
     // Set all members' points to 0
     $output = executeQuery("point.initMemberPoint");
     if (!$output->toBool()) {
         return $output;
     }
     // Save the file temporarily
     $str = '';
     foreach ($member as $key => $val) {
         $val += (int) $config->signup_point;
         $str .= $key . ',' . $val . "\r\n";
     }
     Rhymix\Framework\Storage::write(\RX_BASEDIR . 'files/cache/pointRecal.txt', $str);
     $this->add('total', count($member));
     $this->add('position', 0);
     $this->setMessage(sprintf(lang('point_recal_message'), 0, $this->get('total')));
 }
コード例 #9
0
ファイル: install.controller.php プロジェクト: rhymix/rhymix
 /**
  * @brief Install with received information
  */
 function procInstall($install_config = null)
 {
     // Check if it is already installed
     if (Context::isInstalled()) {
         return new Object(-1, 'msg_already_installed');
     }
     // Get install parameters.
     $config = Rhymix\Framework\Config::getDefaults();
     if ($install_config) {
         $install_config = (array) $install_config;
         $config['db']['master']['type'] = str_replace('_innodb', '', $install_config['db_type']);
         $config['db']['master']['host'] = $install_config['db_hostname'];
         $config['db']['master']['port'] = $install_config['db_port'];
         $config['db']['master']['user'] = $install_config['db_userid'];
         $config['db']['master']['pass'] = $install_config['db_password'];
         $config['db']['master']['database'] = $install_config['db_database'];
         $config['db']['master']['prefix'] = $install_config['db_table_prefix'];
         $config['db']['master']['charset'] = $install_config['db_charset'];
         $config['db']['master']['engine'] = strpos($install_config['db_type'], 'innodb') !== false ? 'innodb' : (strpos($install_config['db_type'], 'mysql') !== false ? 'myisam' : null);
         $config['use_rewrite'] = $install_config['use_rewrite'] === 'Y' ? true : false;
         $config['url']['ssl'] = $install_config['use_ssl'] ?: 'none';
         $time_zone = $install_config['time_zone'];
         $user_info = new stdClass();
         $user_info->email_address = $install_config['email_address'];
         $user_info->password = $install_config['password'];
         $user_info->nick_name = $install_config['nick_name'];
         $user_info->user_id = $install_config['user_id'];
     } else {
         $config['db']['master']['type'] = str_replace('_innodb', '', $_SESSION['db_config']->db_type);
         $config['db']['master']['host'] = $_SESSION['db_config']->db_host;
         $config['db']['master']['port'] = $_SESSION['db_config']->db_port;
         $config['db']['master']['user'] = $_SESSION['db_config']->db_user;
         $config['db']['master']['pass'] = $_SESSION['db_config']->db_pass;
         $config['db']['master']['database'] = $_SESSION['db_config']->db_database;
         $config['db']['master']['prefix'] = $_SESSION['db_config']->db_prefix;
         $config['db']['master']['charset'] = $_SESSION['db_config']->db_charset;
         $config['db']['master']['engine'] = strpos($_SESSION['db_config']->db_type, 'innodb') !== false ? 'innodb' : (strpos($_SESSION['db_config']->db_type, 'mysql') !== false ? 'myisam' : null);
         $config['use_rewrite'] = $_SESSION['use_rewrite'] === 'Y' ? true : false;
         $config['url']['ssl'] = Context::get('use_ssl') ?: 'none';
         $time_zone = Context::get('time_zone');
         $user_info = Context::gets('email_address', 'password', 'nick_name', 'user_id');
     }
     // Fix the database table prefix.
     $config['db']['master']['prefix'] = rtrim($config['db']['master']['prefix'], '_');
     if ($config['db']['master']['prefix'] !== '') {
         $config['db']['master']['prefix'] .= '_';
     }
     // Create new crypto keys.
     $config['crypto']['encryption_key'] = Rhymix\Framework\Security::getRandom(64, 'alnum');
     $config['crypto']['authentication_key'] = Rhymix\Framework\Security::getRandom(64, 'alnum');
     $config['crypto']['session_key'] = Rhymix\Framework\Security::getRandom(64, 'alnum');
     // Set the default language.
     $config['locale']['default_lang'] = Context::getLangType();
     $config['locale']['enabled_lang'] = array($config['locale']['default_lang']);
     // Set the default time zone.
     if (strpos($time_zone, '/') !== false) {
         $config['locale']['default_timezone'] = $time_zone;
         $user_timezone = null;
     } else {
         $user_timezone = intval(Rhymix\Framework\DateTime::getTimezoneOffsetByLegacyFormat($time_zone ?: '+0900') / 3600);
         switch ($user_timezone) {
             case 9:
                 $config['locale']['default_timezone'] = 'Asia/Seoul';
                 break;
             case 0:
                 $config['locale']['default_timezone'] = 'Etc/UTC';
                 break;
             default:
                 $config['locale']['default_timezone'] = 'Etc/GMT' . ($user_timezone > 0 ? '-' : '+') . abs($user_timezone);
         }
     }
     // Set the internal time zone.
     if ($config['locale']['default_timezone'] === 'Asia/Seoul') {
         $config['locale']['internal_timezone'] = 32400;
     } elseif ($user_timezone !== null) {
         $config['locale']['internal_timezone'] = $user_timezone * 3600;
     } else {
         $config['locale']['internal_timezone'] = 0;
     }
     // Set the default URL.
     $config['url']['default'] = Context::getRequestUri();
     // Set the default umask.
     $config['file']['umask'] = Rhymix\Framework\Storage::recommendUmask();
     // Load the new configuration.
     Rhymix\Framework\Config::setAll($config);
     Context::loadDBInfo($config);
     // Check DB.
     $oDB = DB::getInstance();
     if (!$oDB->isConnected()) {
         return $oDB->getError();
     }
     // Assign a temporary administrator while installing.
     foreach ($user_info as $key => $val) {
         Context::set($key, $val, true);
     }
     $user_info->is_admin = 'Y';
     Context::set('logged_info', $user_info);
     // Install all the modules.
     try {
         $oDB->begin();
         $this->installDownloadedModule();
         $oDB->commit();
     } catch (Exception $e) {
         $oDB->rollback();
         return new Object(-1, $e->getMessage());
     }
     // Execute the install script.
     $scripts = FileHandler::readDir(_XE_PATH_ . 'modules/install/script', '/(\\.php)$/');
     if (count($scripts)) {
         sort($scripts);
         foreach ($scripts as $script) {
             $script_path = FileHandler::getRealPath('./modules/install/script/');
             $output = (include $script_path . $script);
         }
     }
     // Apply site lock.
     if (Context::get('use_sitelock') === 'Y') {
         $user_ip_range = getView('install')->detectUserIPRange();
         Rhymix\Framework\Config::set('lock.locked', true);
         Rhymix\Framework\Config::set('lock.message', 'This site is locked.');
         Rhymix\Framework\Config::set('lock.allow', array('127.0.0.1', $user_ip_range));
     }
     // Save the new configuration.
     Rhymix\Framework\Config::save();
     // Unset temporary session variables.
     unset($_SESSION['use_rewrite']);
     unset($_SESSION['db_config']);
     // Redirect to the home page.
     $this->setMessage('msg_install_completed');
     $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : RX_BASEURL;
     $this->setRedirectUrl($returnUrl);
     return new Object();
 }
コード例 #10
0
 /**
  * Get javascript file list
  *
  * @param string $type Type of javascript. head, body
  * @param bool $finalize (optional)
  * @return array Returns javascript file list. Array contains file, targetie.
  */
 public function getJsFileList($type = 'head', $finalize = false)
 {
     if ($type == 'head') {
         $map =& $this->jsHeadMap;
         $mapIndex =& $this->jsHeadMapIndex;
     } else {
         $map =& $this->jsBodyMap;
         $mapIndex =& $this->jsBodyMapIndex;
     }
     $minify = self::$minify !== null ? self::$minify : (config('view.minify_scripts') ?: 'common');
     $concat = strpos(self::$concat !== null ? self::$concat : config('view.concat_scripts'), 'js') !== false;
     $this->_sortMap($map, $mapIndex);
     // Minify all scripts.
     if ($finalize) {
         foreach ($map as $indexedMap) {
             foreach ($indexedMap as $file) {
                 if (!$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && ($file->isCommon && $minify !== 'none' || $minify === 'all')) {
                     $this->proc_CSS_JS($file, true);
                 }
             }
         }
     }
     // Add all files to the final result.
     $result = array();
     if ($concat && $finalize && $type === 'head' && count($concat_list = $this->_concatMap($map))) {
         foreach ($concat_list as $concat_fileset) {
             if (count($concat_fileset) === 1) {
                 $file = reset($concat_fileset);
                 $url = $file->filePath . '/' . $file->fileName;
                 if (!$file->isExternalURL && is_readable($file->fileFullPath)) {
                     $url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
                 }
                 $result[] = array('file' => $url, 'targetie' => $file->targetIe);
             } else {
                 $concat_files = array();
                 $concat_max_timestamp = 0;
                 foreach ($concat_fileset as $file) {
                     $concat_files[] = $file->targetIe ? array($file->fileFullPath, $file->targetIe) : $file->fileFullPath;
                     $concat_max_timestamp = max($concat_max_timestamp, filemtime($file->fileFullPath));
                 }
                 $concat_filename = self::$assetdir . '/combined/' . sha1(serialize($concat_files)) . '.js';
                 if (!file_exists(\RX_BASEDIR . $concat_filename) || filemtime(\RX_BASEDIR . $concat_filename) < $concat_max_timestamp) {
                     Rhymix\Framework\Storage::write(\RX_BASEDIR . $concat_filename, Rhymix\Framework\Formatter::concatJS($concat_files, $concat_filename));
                 }
                 $concat_filename .= '?' . date('YmdHis', filemtime(\RX_BASEDIR . $concat_filename));
                 $result[] = array('file' => \RX_BASEURL . $concat_filename, 'targetie' => '');
             }
         }
     } else {
         foreach ($map as $indexedMap) {
             foreach ($indexedMap as $file) {
                 $url = $file->filePath . '/' . $file->fileName;
                 if (!$file->isExternalURL && is_readable($file->fileFullPath)) {
                     $url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
                 }
                 $result[] = array('file' => $url, 'targetie' => $file->targetIe);
             }
         }
     }
     // Enable HTTP/2 server push for JS resources.
     if ($type === 'head' && $finalize && $this->_isServerPushEnabled()) {
         foreach ($result as $resource) {
             if ($resource['file'][0] === '/' && $resource['file'][1] !== '/') {
                 header(sprintf('Link: <%s>; rel=preload; as=script', $resource['file']), false);
             }
         }
     }
     return $result;
 }