$t = get_t();
if ($phase == 'runtime') {
-
+
$imagecache_directory = file_create_path() .'/imagecache';
if (!file_check_directory($imagecache_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
if (!is_dir($imagecache_directory)) {
$ret[] = update_sql('ALTER TABLE {imagecache_preset} CHANGE rulesetname presetname VARCHAR(255) NOT NULL DEFAULT \'\'');
$ret[] = update_sql('ALTER TABLE {imagecache_action} CHANGE rulesetid presetid INTEGER NOT NULL DEFAULT 0');
break;
-
+
case 'pgsql':
$ret[] = update_sql('ALTER TABLE {imagecache_preset} RENAME COLUMN rulesetid TO presetid');
$ret[] = update_sql('ALTER TABLE {imagecache_preset} RENAME COLUMN rulesetname TO presetname');
}
-/**
+/**
* Remove auto-increment from tables, instead depending on the sequences table and db_next_id()
- */
+ */
function imagecache_update_3() {
$ret = array();
-
+
$count_action = db_result(db_query('SELECT max(actionid) FROM {imagecache_action}')) + 1;
$count_preset = db_result(db_query('SELECT max(presetid) FROM {imagecache_preset}')) + 1;
-
+
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
if ($function == 'scale and crop') {
$function = 'scale_and_crop';
}
- // Keep scale and crop and the old scale function seperate... I don't really want to break BC with
+ // Keep scale and crop and the old scale function seperate... I don't really want to break BC with
// the 2.x update. We'll deprecate this version.
if ($function == 'scale') {
$function = 'deprecated_scale';
* Dynamic image resizer and image cacher.
*
* Imagecache allows you to setup presets for image processing.
- * If an ImageCache derivative doesn't exist the web server's
+ * If an ImageCache derivative doesn't exist the web server's
* rewrite rules will pass the request to Drupal which in turn
* hands it off to imagecache to dynamically generate the file.
- *
- * To view a derivative image you request a special url containing
+ *
+ * To view a derivative image you request a special url containing
* 'imagecache/<presetname>/path/to/file.ext.
*
* Presets can be managed at http://example.com/admin/build/imagecache.
*
- * To view a derivative image you request a special url containing
+ * To view a derivative image you request a special url containing
* 'imagecache/<presetname>/path/to/file.ext.
*
* If you had a preset names 'thumbnail' and you wanted to see the
- * thumbnail version of http://example.com/files/path/to/myimage.jpg you
+ * thumbnail version of http://example.com/files/path/to/myimage.jpg you
* would use http://example.com/files/imagecache/thumbnail/path/to/myimage.jpg
*
- * ImageCache provides formatters for CCK Imagefields and is leveraged by several
+ * ImageCache provides formatters for CCK Imagefields and is leveraged by several
* other modules. ImageCache also relies heavily on ImageAPI for it's image processing.
* If there are errors with actual image processing look to ImageAPI first.
- *
+ *
* @todo: add watermarking capabilities.
- *
+ *
*/
* @return array
* An array of information on the actions implemented by a module. The array
* contains a sub-array for each action node type, with the machine-readable
- * action name as the key. Each sub-array has up to 3 attributes. Possible
+ * action name as the key. Each sub-array has up to 3 attributes. Possible
* attributes:
*
* "name": the human-readable name of the action. Required.
if (!isset($definition_cache[$action])) {
$definitions = imagecache_action_definitions();
$definition = (isset($definitions[$action])) ? $definitions[$action] : array();
-
+
if (isset($definition['file'])) {
require_once($definition['file']);
}
$definition_cache[$action] = $definition;
}
return $definition_cache[$action];
-}
+}
/**
* Return a URL that points to the location of a derivative of the
// preserve path for watchdog.
$src = $path;
-
+
// check if the path to the file exists
if (!is_file($src) && !is_file($src = file_create_path($src))) {
// Send a 404 if we don't know of a preset.
exit;
}
touch($lockfile);
- // register the shtdown function to clean up lock files. by the time shutdown
- // functions are being called the cwd has changed from document root, to
+ // register the shtdown function to clean up lock files. by the time shutdown
+ // functions are being called the cwd has changed from document root, to
// server root so absolute paths must be used for files in shutdown functions.
register_shutdown_function('file_delete', realpath($lockfile));
/**
* build an image cache derivative
- *
+ *
* @param $actions Array of imagecache actions.
* @param $src Path of the source file.
* @param $dst Path of the destination file.
$dir = dirname($dst);
// Build the destination folder tree if it doesn't already exists.
- if (!file_check_directory($dir) && !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;
}
if (!$image = imageapi_image_open($src)) {
- return false;
+ return false;
}
foreach ($actions as $action) {
$parts = explode('_', $formatter);
$style = array_pop($parts);
$presetname = implode('_', $parts);
-
+
$class = "imagecache imagecache-$presetname imagecache-$style imagecache-$formatter";
if ($preset = imagecache_preset_by_name($presetname)) {
$item['filepath'] = $item['fid'] == 'upload' ? $item['preview'] : $item['filepath'];
case 'linked':
$imagetag = theme('imagecache', $presetname, $item['filepath'], $alt, $title);
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);
function _imagecache_recursive_delete($path) {
if (is_file($path) || is_link($path)) {
unlink($path);
- }
+ }
elseif (is_dir($path)) {
$d = dir($path);
while (($entry = $d->read()) !== false) {
rmdir($path);
}
else {
- watchdog('imagecache', 'Unknown file type(%path) stat: %stat ',
+ watchdog('imagecache', 'Unknown file type(%path) stat: %stat ',
array('%path' => $path, '%stat' => print_r(stat($path),1)), WATCHDOG_ERROR);
}
-
+
}
/**
* @param $title
* img tag title text
* @param attributes
- * optional drupal attributes array. If attributes is set, the default imagecache classes
+ * optional drupal attributes array. If attributes is set, the default imagecache classes
* will not be set automatically, you must do this manually.
*/
function theme_imagecache($namespace, $path, $alt = '', $title = '', $attributes = NULL) {
$attributes['height'] = $image['height'];
}
// check is_null so people can intentionally pass an empty array of attributes to override
- // the defaults completely... if
+ // the defaults completely... if
if (is_null($attributes)) {
$attributes['class'] = 'imagecache imagecache-'. $namespace;
- }
+ }
$attributes = drupal_attributes($attributes);
$imagecache_url = imagecache_create_url($namespace, $path);
return '<img src="'. $imagecache_url .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $attributes .' />';
/**
* ImageCache 2.x API
*
- * The API for imagecache has changed. The 2.x API returns more structured
- * data, has shorter function names, and implements more aggressive metadata
+ * The API for imagecache has changed. The 2.x API returns more structured
+ * data, has shorter function names, and implements more aggressive metadata
* caching.
*
*/
$preset = imagecache_preset($action['presetid']);
imagecache_preset_flush($preset);
imagecache_presets(true);
- return $action;
+ return $action;
}
function imagecache_action_delete($action) {