public function getTemplateVars() { $ret = parent::getTemplateVars(); $c = $this->getData()->parent->getComponent(); $size = $c->getImageDimensions(); $ret['width'] = $size['width']; $ret['height'] = $size['height']; $ret['imageUrl'] = $c->getImageUrl(); $ret['options'] = (object) $c->getOptions(); // Next-Previous Links $imageEnlarge = $this->getData()->parent->parent; if (is_instance_of($imageEnlarge->componentClass, 'Kwc_Basic_ImageEnlarge_Component') || is_instance_of($imageEnlarge->componentClass, 'Kwc_Basic_ImageEnlargeParent_Component')) { // Only show links when it's an ImageEnlarge (no LinkTag) $parent = $imageEnlarge->parent; $getChildren = array(); if (is_instance_of($parent->componentClass, 'Kwc_Abstract_List_Component')) { //it's in an List_Gallery } else { if ($parent->parent && is_instance_of($parent->parent->componentClass, 'Kwc_Abstract_List_Component')) { //it's in an List_Switch with ImageEnlarge as large component (we have to go up one more level) $getChildren = array('-' . $imageEnlarge->id); $imageEnlarge = $imageEnlarge->parent; } } $links = self::getPreviousAndNextImagePage($this->getData()->componentClass, $imageEnlarge, $getChildren); $ret = array_merge($ret, $links); } else { $ret['next'] = null; $ret['previous'] = null; } $imageData = $c->getImageData(); $ret = array_merge($ret, Kwf_Media_Output_Component::getResponsiveImageVars($size, $imageData['file'])); $ret['baseUrl'] = $c->getBaseImageUrl(); return $ret; }
/** * Checks if given type (starting with Kwf_Media::DONT_HASH_TYPE_PREFIX) should * return an image by checking Kwf_Media_Image::getResponsiveWidthSteps of image */ public static function isValidImage($id, $type, $className) { $isValid = Kwf_Media_Output_Component::isValid($id); if ($isValid == Kwf_Media_Output_IsValidInterface::VALID || $isValid == Kwf_Media_Output_IsValidInterface::VALID_DONT_CACHE) { // Can be searched with ignore-visible because if it is invisble and // not allowed to show Kwf_Media_Output_Component::isValid would return // invalid or access_denied $c = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible' => true)); if (!$c) { return Kwf_Media_Output_IsValidInterface::INVALID; } if ($c->componentClass != $className) { return Kwf_Media_Output_IsValidInterface::INVALID; } $baseType = $c->getComponent()->getBaseType(); $dim = $c->getComponent()->getImageDimensions(); $imageData = $c->getComponent()->getImageDataOrEmptyImageData(); $widths = Kwf_Media_Image::getResponsiveWidthSteps($dim, isset($imageData['image']) ? $imageData['image'] : $imageData['file']); $ok = false; foreach ($widths as $w) { if (str_replace('{width}', $w, $baseType) == $type) { $ok = true; break; } } if (!$ok) { $isValid = Kwf_Media_Output_IsValidInterface::INVALID; } } return $isValid; }
public static function isValidMediaOutput($id, $type, $className) { $componentId = substr($id, 0, strrpos($id, '_')); $component = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($componentId); if ($component) { return Kwf_Media_Output_Component::isValid($component->componentId); } else { return Kwf_Media_Output_IsValidInterface::INVALID; } }
protected function checkAllowed() { $valid = Kwf_Media_Output_Component::isValid($this->_data->componentId); if ($valid == Kwf_Media_Output_IsValidInterface::ACCESS_DENIED) { // send non pdf content to show login-plugin $contentSender = new Kwf_Component_Abstract_ContentSender_Default($this->_data); $contentSender->sendContent(true); return false; } else { if ($valid == Kwf_Media_Output_IsValidInterface::INVALID) { throw new Kwf_Exception_NotFound(); } } return $valid; }
public static function isValidMediaOutput($id, $type, $className) { return Kwf_Media_Output_Component::isValid($id); }
public static function getMediaOutput($id, $type, $className) { $component = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible' => true)); if (!$component) { return null; } $data = $component->getComponent()->getImageDataOrEmptyImageData(); if (!$data) { return null; } $dimension = $component->getComponent()->getImageDimensions(); return Kwf_Media_Output_Component::getMediaOutputForDimension($data, $dimension, $type); }
public static function getMediaOutput($id, $type, $className) { $component = Kwf_Component_Data_Root::getInstance()->getComponentById($id, array('ignoreVisible' => true)); if (!$component) { return null; } $data = $component->getComponent()->getImageData(); if (!$data) { return null; } if ($type == 'original') { return array('file' => $data['file'], 'downloadFilename' => $data['filename'], 'mimeType' => $data['mimeType']); } else { $dimension = $component->getComponent()->getImageDimensions(); return Kwf_Media_Output_Component::getMediaOutputForDimension($data, $dimension, $type); } }