* @return
* An array of actions to be used when transforming images.
*/
-function imagecache_action_definitions($reset = false) {
+function imagecache_action_definitions($reset = FALSE) {
static $actions;
if (!isset($actions) || $reset) {
if (!$reset && ($cache = cache_get('imagecache_actions')) && !empty($cache->data)) {
* @param $image
* Image object
* @return
- * Boolean, true indicating success and false failure.
+ * Boolean, TRUE indicating success and FALSE failure.
*/
function _imagecache_apply_action($action, $image) {
$actions = imagecache_action_definitions();
}
// skip undefined actions.. module probably got uninstalled or disabled.
watchdog('imagecache', 'non-existant action %action', array('%action' => $action['action']), WATCHDOG_NOTICE);
- return true;
+ return TRUE;
}
/**
// See if the client has provided the required HTTP headers:
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE'])
- : false;
+ : FALSE;
$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH'])
? stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])
- : false;
+ : FALSE;
if ($if_modified_since && $if_none_match
&& $if_none_match == $etag // etag must match
* @param $src Path of the source file.
* @param $dst Path of the destination file.
* @param $tmp Path of the temporary file used for manipulating the image.
- * @return true - derivative generated, false - no derivative generated, null - derivative being generated
+ * @return TRUE - derivative generated, FALSE - no derivative generated, NULL - derivative being generated
*/
function imagecache_build_derivative($actions, $src, $dst) {
// get the folder for the final location of this preset...
$dir = dirname($dst);
// Build the destination folder tree if it doesn't already exists.
- if (!file_check_directory($dir, FILE_CREATE_DIRECTORY) && !mkdir($dir, 0775, true)) {
+ if (!file_check_directory($dir, FILE_CREATE_DIRECTORY) && !mkdir($dir, 0775, TRUE)) {
watchdog('imagecache', 'Failed to create imagecache directory: %dir', array('%dir' => $dir), WATCHDOG_ERROR);
- return false;
+ return FALSE;
}
// Simply copy the file if there are no actions.
}
if (!$image = imageapi_image_open($src)) {
- return false;
+ return FALSE;
}
foreach ($actions as $action) {
}
if (!_imagecache_apply_action($action, $image)) {
watchdog('imagecache', 'action(id:%id): %action failed for %src', array('%id' => $action['actionid'], '%action' => $action['action'], '%src' => $src), WATCHDOG_ERROR);
- return false;
+ return FALSE;
}
}
if (file_exists($dst)) {
watchdog('imagecache', 'Cached image file %dst already exists. There may be an issue with your rewrite configuration.', array('%dst' => $dst), WATCHDOG_ERROR);
}
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
/**
switch ($style) {
case 'linked':
$imagetag = theme('imagecache', $presetname, $item['filepath'], $alt, $title);
- return l($imagetag, 'node/'. $node->nid, array('attributes' => array('class' => $class), 'html' => true));
+ return l($imagetag, 'node/'. $node->nid, array('attributes' => array('class' => $class), 'html' => TRUE));
case 'imagelink':
$original_image_url = file_create_url($item['filepath']);
$imagetag = theme('imagecache', $presetname, $item['filepath'], $alt, $title);
- return l($imagetag, $original_image_url, array('attributes' => array('class' => $class), 'html' => true));
+ return l($imagetag, $original_image_url, array('attributes' => array('class' => $class), 'html' => TRUE));
case 'url':
return imagecache_create_url($presetname, $item['filepath']);
* Filter key word values such as 'top', 'right', 'center', and also percentages.
* All returned values are in pixels relative to the passed in height and width.
*/
-function _imagecache_filter($key, $value, $current_width, $current_height, $new_width = null, $new_height = null) {
+function _imagecache_filter($key, $value, $current_width, $current_height, $new_width = NULL, $new_height = NULL) {
switch ($key) {
case 'width':
$value = _imagecache_percent_filter($value, $current_width);
* Accept a percentage and return it in pixels.
*/
function _imagecache_percent_filter($value, $current_pixels) {
- if (strpos($value, '%') !== false) {
+ if (strpos($value, '%') !== FALSE) {
$value = str_replace('%', '', $value) * 0.01 * $current_pixels;
}
return $value;
}
elseif (is_dir($path)) {
$d = dir($path);
- while (($entry = $d->read()) !== false) {
+ while (($entry = $d->read()) !== FALSE) {
if ($entry == '.' || $entry == '..') continue;
$entry_path = $path .'/'. $entry;
_imagecache_recursive_delete($entry_path);
function imagecache_resize_image(&$image, $data) {
if (!imageapi_image_resize($image, $data['width'], $data['height'])) {
watchdog('imagecache', 'imagecache_resize_image failed. image: %image, data: %data.', array('%path' => $image, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
function imagecache_resize_form($action) {
* Get an array of all presets and their settings.
*
* @param reset
- * if set to true it will clear the preset cache
+ * if set to TRUE it will clear the preset cache
*
* @return
* array of presets array( $preset_id => array('presetid' => integer, 'presetname' => string))
*/
-function imagecache_presets($reset = false) {
+function imagecache_presets($reset = FALSE) {
static $presets = array();
- // Clear caches if $reset is true;
+ // Clear caches if $reset is TRUE;
if ($reset) {
$presets = array();
cache_clear_all('imagecache:presets', 'cache');
* preset array( 'presetname' => string, 'presetid' => integet)
* empty array if preset_id is an invalid preset
*/
-function imagecache_preset($preset_id, $reset = false) {
+function imagecache_preset($preset_id, $reset = FALSE) {
$presets = imagecache_presets($reset);
return (isset($presets[$preset_id])) ? $presets[$preset_id] : array();
}
// Reset presets cache.
imagecache_preset_flush($preset);
- imagecache_presets(true);
+ imagecache_presets(TRUE);
// Rebuild Theme Registry
drupal_rebuild_theme_registry();
imagecache_preset_flush($preset['presetid']);
db_query('DELETE FROM {imagecache_action} where presetid = %d', $preset['presetid']);
db_query('DELETE FROM {imagecache_preset} where presetid = %d', $preset['presetid']);
- imagecache_presets(true);
- return true;
+ imagecache_presets(TRUE);
+ return TRUE;
}
-function imagecache_preset_actions($preset, $reset = false) {
+function imagecache_preset_actions($preset, $reset = FALSE) {
static $actions_cache = array();
if ($reset || empty($actions_cache[$preset['presetid']])) {
}
$preset = imagecache_preset($action['presetid']);
imagecache_preset_flush($preset);
- imagecache_presets(true);
+ imagecache_presets(TRUE);
return $action;
}
db_query('DELETE FROM {imagecache_action} WHERE actionid=%d', $action['actionid']);
$preset = imagecache_preset($action['presetid']);
imagecache_preset_flush($preset);
- imagecache_presets(true);
+ imagecache_presets(TRUE);
}
$data['width'] = $data['width'] ? $data['width'] : 9999999;
$data['height'] = $data['height'] ? $data['height'] : 9999999;
if (!imageapi_image_scale($image, $data['width'], $data['height'], $data['upscale'])) {
- watchdog('imagecache', 'imagecache_scale_image failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, true)), WATCHDOG_ERROR);
- return false;
+ watchdog('imagecache', 'imagecache_scale_image failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+ return FALSE;
}
- return true;
+ return TRUE;
}
function imagecache_scale_and_crop_image(&$image, $data) {
if (!imageapi_image_scale_and_crop($image, $data['width'], $data['height'])) {
- watchdog('imagecache', 'imagecache_scale_and_crop failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, true)), WATCHDOG_ERROR);
- return false;
+ watchdog('imagecache', 'imagecache_scale_and_crop failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+ return FALSE;
}
- return true;
+ return TRUE;
}
$data['width'] = $data['width'] ? $data['width'] : 9999999;
$data['height'] = $data['height'] ? $data['height'] : 9999999;
if (!imageapi_image_scale($image, $data['width'], $data['height'])) {
- watchdog('imagecache', 'imagecache_deprecated_scale failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, true)), WATCHDOG_ERROR);
- return false;
+ watchdog('imagecache', 'imagecache_deprecated_scale failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+ return FALSE;
}
- return true;
+ return TRUE;
}
function imagecache_crop_image(&$image, $data) {
if (!imageapi_image_crop($image, $data['xoffset'], $data['yoffset'], $data['width'], $data['height'])) {
- watchdog('imagecache', 'imagecache_crop failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, true)), WATCHDOG_ERROR);
- return false;
+ watchdog('imagecache', 'imagecache_crop failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+ return FALSE;
}
- return true;
+ return TRUE;
}
function imagecache_desaturate_image(&$image, $data = array()) {
if (!imageapi_image_desaturate($image)) {
- watchdog('imagecache', 'imagecache_desaturate failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, true)), WATCHDOG_ERROR);
- return false;
+ watchdog('imagecache', 'imagecache_desaturate failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+ return FALSE;
}
- return true;
+ return TRUE;
}
function imagecache_rotate_image(&$image, $data) {
// Set sane default values.
$data['degrees'] = $data['degrees'] ? $data['degrees'] : 0;
- $data['random'] = $data['random'] ? $data['random'] : false;
+ $data['random'] = $data['random'] ? $data['random'] : FALSE;
$data['bgcolor'] = $data['bgcolor'] ? $data['bgcolor'] : '#FFFFFF';
// Manipulate the if we need to randomize, and convert to proper colors.
}
if (!imageapi_image_rotate($image, $data['degrees'], $data['bgcolor'])) {
- watchdog('imagecache', 'imagecache_rotate_image failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, true)), WATCHDOG_ERROR);
- return false;
+ watchdog('imagecache', 'imagecache_rotate_image failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+ return FALSE;
}
- return true;
+ return TRUE;
}
/**
$data['threshold'] = $data['threshold'] ? $data['threshold'] : "0.05";
if (!imageapi_image_sharpen($image, $data['radius'], $data['sigma'], $data['amount'], $data['threshold'])) {
- watchdog('imagecache', 'imagecache_sharpen_image failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, true)), WATCHDOG_ERROR);
- return false;
+ watchdog('imagecache', 'imagecache_sharpen_image failed. image: %image, data: %data.', array('%image' => $image->source, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
+ return FALSE;
}
- return true;
+ return TRUE;
}