/** * Checks if currently loaded representation is of specified media class. Valid media classes are 'image', 'audio', 'video' and 'document' * * @param string The media class to check for * @return True if representation is of specified class, false if not */ public function representationIsOfClass($ps_class) { if (!($vs_mimetypes_regex = caGetMimetypesForClass($ps_class, array('returnAsRegex' => true)))) { return array(); } return preg_match("!{$vs_mimetypes_regex}!", $this->get('mimetype')) ? true : false; }
/** * Returns information for representations of the specified class attached to the current item. * * @param string $ps_class The class of representation to return information for. Valid classes are "image", "audio", "video" and "document" * @param array $pa_options Options for selection of representations to return; same as options for self::getRepresentations() * * @return array An array with information about matching representations, in the same format as that returned by self::getRepresentations() */ public function representationsOfClass($ps_class, $pa_versions = null, $pa_version_sizes = null, $pa_options = null) { if (!($vs_mimetypes_regex = caGetMimetypesForClass($ps_class, array('returnAsRegex' => true)))) { return array(); } $va_rep_list = array(); if (is_array($va_reps = $this->getRepresentations($pa_versions, $pa_version_sizes, $pa_options))) { foreach ($va_reps as $vn_rep_id => $va_rep) { if (preg_match("!{$vs_mimetypes_regex}!", $va_rep['mimetype'])) { $va_rep_list[$vn_rep_id] = $va_rep; } } } return $va_rep_list; }