/** * Base generate function. Detect all using maps (incoming map_id & it's attach * and sub-sub-...-attach maps). Check validate of cache files. Then if need * generate data and make redirect to CSS-file. * If $get_link is true then return path to file * * @param string $map_id * * @param bool $get_link * * @return bool global execute status */ public static function execute($map_id, $get_link = FALSE) { list($map_id) = explode(':', $map_id); $need_get_maps_stack = array($map_id); $valid_maps_stack = array(); $invalid_maps_stack = array(); while (count($need_get_maps_stack) > 0) { $one_map_id = array_shift($need_get_maps_stack); $one_map_cfg = qpimg_config::get_map($one_map_id); if ($one_map_cfg === false) { return false; } if (isset($one_map_cfg['attach']) === true) { if (is_array($one_map_cfg['attach']) === false) { $one_map_cfg['attach'] = array($one_map_cfg['attach']); } foreach ($one_map_cfg['attach'] as $attach_map_id) { if (isset($valid_maps_stack[$attach_map_id]) === false && isset($invalid_maps_stack[$attach_map_id]) === false) { $need_get_maps_stack[] = $attach_map_id; } } } //--------------------------------------------------------------------- // Check for data in cache if (qpimg_cache::validate($one_map_cfg) === true) { $valid_maps_stack[$one_map_id] = $one_map_cfg; } else { if (qpimg_cache::clean($one_map_cfg) === false) { return false; } $invalid_maps_stack[$one_map_id] = $one_map_cfg; } if ($map_id == $one_map_id) { $map_cfg = $one_map_cfg; } } if (count($invalid_maps_stack) > 0) { if (isset($invalid_maps_stack[$map_id]) === false) { $invalid_maps_stack[$map_id] = $valid_maps_stack[$map_id]; unset($valid_maps_stack[$map_id]); } //--------------------------------------------------------------------- // Generate data foreach ($invalid_maps_stack as $one_map_id => $one_map_cfg) { if (qpimg_media::pack($one_map_cfg) === false) { return false; } $valid_maps_stack[$one_map_id] = $invalid_maps_stack[$one_map_id]; } qpimg_cache::clean($one_map_cfg, true); if (qpimg_media::pack_grouper_css($map_cfg, $valid_maps_stack) === false) { return false; } //--------------------------------------------------------------------- } return $get_link ? qpimg_cache::get_valid_css_source($map_cfg, isset($map_cfg['attach'])) : qpimg_cache::redirect($map_cfg); }