CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SPTImage Class Reference

Encapsulates a full-size, preview, and thumbnail image. More...

## Public Member Functions
| __construct ($ImageIdOrFileNameOrImageObj, $MaxWidth=NULL, $MaxHeight=NULL, $MaxPreviewWidth=NULL, $MaxPreviewHeight=NULL, $MaxThumbnailWidth=NULL, $MaxThumbnailHeight=NULL)
| Object constructor. More...
| Id ()
| Get the ID of the image in the database. More...
| Url ()
| Get the path to the image. More...
| PreviewUrl ()
| Get the path to the preview image for this image. More...
| ThumbnailUrl ()
| Get the path to the thumbnail image for this image. More...
| Format ()
| Get the format of the image. More...
| Mimetype ()
| Get the MIME type for the image. More...
| Height ()
| Get the height of the image. More...
| Width ()
| Get the width of the image. More...
| PreviewHeight ()
| Get the height of the preview image for this image. More...
| PreviewWidth ()
| Get the width of the preview image for this image. More...
| ThumbnailHeight ()
| Get the height of the thumbnail image for this image. More...
| ThumbnailWidth ()
| Get the width of the thumbnail image for this image. More...
| GetLink ()
| Get the path to the full-size image. More...
| AltText ($NewValue=NULL)
| Get or set the alternate text value for the image. More...
| LinkTarget ($NewValue=NULL)
| Get or set the link target value for the image. More...
| Delete ()
| Delete the image, that is, remove its record from the database and delete the associated image files from the file system. More...
| Status ()
| Get the error status set by the constructor. More...
| Resize ($MaxWidth, $MaxHeight, $MaxPreviewWidth, $MaxPreviewHeight, $MaxThumbnailWidth, $MaxThumbnailHeight)
| Resize the full-size, preview, and thumbnail images based on the given dimension restrictions. More...
| GetImageUrlForResource ($ResourceId, $FieldId, $Index, $Size)
| Get the URL pointing to an image. More...

## Static Public Member Functions
static | ImageStorageDirectory ()
| Get the path to the (full-size) image storage directory. More...
static | PreviewStorageDirectory ()
| Get the path to the preview image storage directory. More...
static | ThumbnailStorageDirectory ()
| Get the path to the thumbnail image storage directory. More...
static | CheckDirectories ()
| Check that the image storage directories are available, creating them and attempting to change their permissions if possible. More...
static | ClearImageSymlinksForResource ($ResourceId, $FieldId)
| Remove symlinks used for to cache image mappings. More...
static | ClearImageSymlinks ()
| Remove all symlinks used for a cached image mapping. More...
static | ExpireImageSymlinks ()
| Expire old symlinks used for cached image mappings. More...

## Public Attributes
const | CACHE_PATH = "local/data/caches/ImageLinks"
| path containg the symlinks mapping images/fields to resources More...
const | SIZE_FULL = 3
const | SIZE_PREVIEW = 2
const | SIZE_THUMBNAIL = 1

## Detailed Description

Encapsulates a full-size, preview, and thumbnail image.

Definition at line 13 of file SPTImage.php.

## Constructor & Destructor Documentation

SPTImage::__construct | ( |  | $ImageIdOrFileNameOrImageObj,
|  |  | $MaxWidth = `NULL`,
|  |  | $MaxHeight = `NULL`,
|  |  | $MaxPreviewWidth = `NULL`,
|  |  | $MaxPreviewHeight = `NULL`,
|  |  | $MaxThumbnailWidth = `NULL`,
|  |  | $MaxThumbnailHeight = `NULL`
| ) |  |

Object constructor.

This loads an image if an ID is given or copies an image if either an SPTImage object or file path are passed in.

Parameters

  mixed | $ImageIdOrFileNameOrImageObj | Image ID, image file name, or SPTImage.
  int | $MaxWidth | Maximum width of the full-size image.
  int | $MaxHeight | Maximum height of the full-size image.
  int | $MaxPreviewWidth | Maximum width of the preview image.
  int | $MaxPreviewHeight | Maximum height of the preview image.
  int | $MaxThumbnailWidth | Maximum width of the thumbnail image.
  int | $MaxThumbnailHeight | Maximum height of the thumbnail image.

Definition at line 37 of file SPTImage.php.

## Member Function Documentation

SPTImage::AltText | ( |  | $NewValue = `NULL` | ) |

Get or set the alternate text value for the image.

Parameters

  string | $NewValue | New alternate text value. This parameter is optional.

Returns
  Returns the current alternate text value.

Definition at line 284 of file SPTImage.php.

References Id().

Referenced by ExpireImageSymlinks().

Here is the caller graph for this function:

static SPTImage::CheckDirectories | ( |  | ) |
| static

Check that the image storage directories are available, creating them and attempting to change their permissions if possible.

Returns
  Returns an array of error codes or NULL if no errors are found.

Definition at line 353 of file SPTImage.php.

static SPTImage::ClearImageSymlinks | ( |  | ) |
| static

Remove all symlinks used for a cached image mapping.

Definition at line 601 of file SPTImage.php.

static SPTImage::ClearImageSymlinksForResource | ( |  | $ResourceId,
|  |  | $FieldId
| ) |  |
| static

Remove symlinks used for to cache image mappings.

Parameters

  int | $ResourceId | Source resource.
  int | $FieldId | Source field.

Definition at line 576 of file SPTImage.php.

References StdLib\CheckMyCaller().

Referenced by Resource\Clear(), and Resource\Set().

Here is the caller graph for this function:

SPTImage::Delete | ( |  | ) |

Delete the image, that is, remove its record from the database and delete the associated image files from the file system.

Definition at line 324 of file SPTImage.php.

References Id().

static SPTImage::ExpireImageSymlinks | ( |  | ) |
| static

Expire old symlinks used for cached image mappings.

Definition at line 621 of file SPTImage.php.

References AI_FILEUNREADABLE, AI_INTERNALERROR, AI_OKAY, AltText(), Image\Extension(), Format(), Height(), Id(), LinkTarget(), PreviewHeight(), PreviewWidth(), Image\Status(), ThumbnailHeight(), ThumbnailWidth(), and Width().

SPTImage::Format | ( |  | ) |

Get the format of the image.

The value will be one IMGTYPE_* constants from the Image class.

Returns
  Returns the format of the image.

Definition at line 137 of file SPTImage.php.

Referenced by ExpireImageSymlinks(), and GetImageUrlForResource().

Here is the caller graph for this function:

SPTImage::GetImageUrlForResource | ( |  | $ResourceId,
|  |  | $FieldId,
|  |  | $Index,
|  |  | $Size
| ) |  |

Get the URL pointing to an image.

Parameters

  int | $ResourceId | Source resource.
  int | $FieldId | Source field.
  int | $Index | Image number w/in this field.
  int | $Size | Image size as an SPTImage::SIZE_ const.

Definition at line 508 of file SPTImage.php.

References StdLib\CheckMyCaller(), Image\Extension(), and Format().

SPTImage::GetLink | ( |  | ) |

Get the path to the full-size image.

Returns
  Returns the path to the full-size image.

Definition at line 273 of file SPTImage.php.

SPTImage::Height | ( |  | ) |

Get the height of the image.

Returns
  Returns the height of the image.

Definition at line 156 of file SPTImage.php.

Referenced by ExpireImageSymlinks(), and Resize().

Here is the caller graph for this function:

SPTImage::Id | ( |  | ) |

Get the ID of the image in the database.

Returns
  Returns the ID of the image in the database.

Definition at line 82 of file SPTImage.php.

Referenced by AltText(), Delete(), ExpireImageSymlinks(), and LinkTarget().

Here is the caller graph for this function:

static SPTImage::ImageStorageDirectory | ( |  | ) |
| static

Get the path to the (full-size) image storage directory.

Returns
  Returns the path to the full-size image storage directory.

Definition at line 210 of file SPTImage.php.

SPTImage::LinkTarget | ( |  | $NewValue = `NULL` | ) |

Get or set the link target value for the image.

Parameters

  string | $NewValue | New value for link target (OPTIONAL)

Returns
  current LinkTarget value

Definition at line 307 of file SPTImage.php.

References Id().

Referenced by ExpireImageSymlinks().

Here is the caller graph for this function:

SPTImage::Mimetype | ( |  | ) |

Get the MIME type for the image.

Returns
  Returns the MIME type for the image.

Definition at line 146 of file SPTImage.php.

SPTImage::PreviewHeight | ( |  | ) |

Get the height of the preview image for this image.

Returns
  Returns the height of the preview image for this image.

Definition at line 174 of file SPTImage.php.

Referenced by ExpireImageSymlinks(), and Resize().

Here is the caller graph for this function:

static SPTImage::PreviewStorageDirectory | ( |  | ) |
| static

Get the path to the preview image storage directory.

Returns
  Returns the path to the preview image storage directory.

Definition at line 231 of file SPTImage.php.

SPTImage::PreviewUrl | ( |  | ) |

Get the path to the preview image for this image.

Returns
  Returns the path to the preview image for this image.

Definition at line 106 of file SPTImage.php.

SPTImage::PreviewWidth | ( |  | ) |

Get the width of the preview image for this image.

Returns
  Returns the width of the preview image for this image.

Definition at line 183 of file SPTImage.php.

Referenced by ExpireImageSymlinks(), and Resize().

Here is the caller graph for this function:

SPTImage::Resize | ( |  | $MaxWidth,
|  |  | $MaxHeight,
|  |  | $MaxPreviewWidth,
|  |  | $MaxPreviewHeight,
|  |  | $MaxThumbnailWidth,
|  |  | $MaxThumbnailHeight
| ) |  |

Resize the full-size, preview, and thumbnail images based on the given dimension restrictions.

Parameters

  int | $MaxWidth | Maximum width of the full-size image.
  int | $MaxHeight | Maximum height of the full-size image.
  int | $MaxPreviewWidth | Maximum width of the preview image.
  int | $MaxPreviewHeight | Maximum height of the preview image.
  int | $MaxThumbnailWidth | Maximum width of the thumbnail image.
  int | $MaxThumbnailHeight | Maximum height of the thumbnail image.

Definition at line 440 of file SPTImage.php.

References Height(), PreviewHeight(), PreviewWidth(), ThumbnailHeight(), ThumbnailWidth(), and Width().

SPTImage::Status | ( |  | ) |

Get the error status set by the constructor.

Returns
  Returns the error status set by the constructor.

Definition at line 343 of file SPTImage.php.

SPTImage::ThumbnailHeight | ( |  | ) |

Get the height of the thumbnail image for this image.

Returns
  Returns the height of the thumbnail image for this image.

Definition at line 192 of file SPTImage.php.

Referenced by ExpireImageSymlinks(), and Resize().

Here is the caller graph for this function:

static SPTImage::ThumbnailStorageDirectory | ( |  | ) |
| static

Get the path to the thumbnail image storage directory.

Returns
  Returns the path to the thumbnail image storage directory.

Definition at line 252 of file SPTImage.php.

SPTImage::ThumbnailUrl | ( |  | ) |

Get the path to the thumbnail image for this image.

Returns
  Returns the path to the thumbnail image for this image.

Definition at line 121 of file SPTImage.php.

SPTImage::ThumbnailWidth | ( |  | ) |

Get the width of the thumbnail image for this image.

Returns
  Returns the width of the thumbnail image for this image.

Definition at line 201 of file SPTImage.php.

Referenced by ExpireImageSymlinks(), and Resize().

Here is the caller graph for this function:

SPTImage::Url | ( |  | ) |

Get the path to the image.

Returns
  Returns the path to the image.

Definition at line 91 of file SPTImage.php.

SPTImage::Width | ( |  | ) |

Get the width of the image.

Returns
  Returns the width of the image.

Definition at line 165 of file SPTImage.php.

Referenced by ExpireImageSymlinks(), and Resize().

Here is the caller graph for this function:

## Member Data Documentation

const SPTImage::CACHE_PATH = "local/data/caches/ImageLinks"

path containg the symlinks mapping images/fields to resources

Definition at line 19 of file SPTImage.php.

const SPTImage::SIZE_FULL = 3

Definition at line 21 of file SPTImage.php.

const SPTImage::SIZE_PREVIEW = 2

Definition at line 22 of file SPTImage.php.

const SPTImage::SIZE_THUMBNAIL = 1

Definition at line 23 of file SPTImage.php.

The documentation for this class was generated from the following file:

- objects/SPTImage.php