/** * Returns the URL to the cache file, should it exist * @param string $cache_key * @return string * @author Jesse Bunch */ private function _get_cache_url_path($cache_key) { $cache_path = Craft()->automin->getSetting('autominCacheURL'); return $this->remove_double_slashes("{$cache_path}/{$cache_key}"); }
public function read($path = '') { return Craft()->directoryContents->read($path); }
/** * Main processing routine, to be used for all types * @param $markup * @param $markup_type One of the MARKUP_TYPE_X values * @param $markup_attrs tag attributes string * @return string The new markup * @author Jesse Bunch */ private function _process_markup($markup, $markup_type, $markup_attrs) { // AutoMin disabled? Go no further... if (!$this->getSetting('autominEnabled')) { return $markup; } // Gather information $filename_array = $this->_extract_filenames($markup, $markup_type); $filename_array = $this->_prep_filenames($filename_array); $last_modified = $this->_find_last_modified_timestamp($filename_array); // File Extension // LESS files should have a .css extension $extension = $markup_type == self::MARKUP_TYPE_LESS || $markup_type == self::MARKUP_TYPE_SCSS ? self::MARKUP_TYPE_CSS : $markup_type; $cache_key = Craft()->automin_cache->get_cache_key($markup, $extension); // Fetch and validate cache, if caching is enabled if ($this->getSetting('autominCachingEnabled')) { $cache_filename = Craft()->automin_cache->fetch_cache($cache_key, $markup, $last_modified); // Output cache file, if valid if (FALSE !== $cache_filename) { $this->_write_log("Cache found and valid"); return $this->_format_output($cache_filename, $last_modified, $markup_type, $markup_attrs); } } // Combine files, parse @imports if appropriate $combined_file_data = $this->_combine_files($filename_array, $markup_type == self::MARKUP_TYPE_CSS or $markup_type == self::MARKUP_TYPE_LESS); // If we couldn't read some files, return original tags if (FALSE === $combined_file_data) { $this->_write_log("ERROR: One or more of your files couldn't be read."); return $markup; } // Attempt compilation and compression $data_length_before = strlen($combined_file_data) / 1024; $combined_file_data = $this->_compile_and_compress($combined_file_data, $markup_type); $data_length_after = strlen($combined_file_data) / 1024; // Log the savings $data_savings_kb = $data_length_before - $data_length_after; $data_savings_percent = $data_savings_kb / $data_length_before * 100; $data_savings_message = sprintf('(%s Compression) Before: %1.0fkb / After: %1.0fkb / Data reduced by %1.2fkb or %1.2f%%', strtoupper($markup_type), $data_length_before, $data_length_after, $data_savings_kb, $data_savings_percent); $this->_write_log($data_savings_message); // If compilation fails, return original tags if (FALSE === $combined_file_data) { $this->_write_log("ERROR: Compilation failed. Perhaps you have a syntax error?"); return $markup; } // Cache output $cache_result = Craft()->automin_cache->write_cache($cache_key, $combined_file_data); // If caching failed, return original tags if (FALSE === $cache_result) { $this->_write_log("ERROR: Caching is disabled or we were unable to write to your cache directory."); return $markup; } // Return the markup output return $this->_format_output($cache_result, $last_modified, $markup_type, $markup_attrs); }
public function actionSaveJob() { //echo "save"; Craft()->jobsApi_jobs->saveJob(); }