本文整理汇总了PHP中Asset::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Asset::getType方法的具体用法?PHP Asset::getType怎么用?PHP Asset::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset
的用法示例。
在下文中一共展示了Asset::getType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDependencyForFrontend
/**
* @param Document|Asset|Object_Abstract $element
* @return array
*/
public static function getDependencyForFrontend($element)
{
if ($element instanceof Document) {
return array("id" => $element->getId(), "path" => $element->getFullPath(), "type" => "document", "subtype" => $element->getType());
} else {
if ($element instanceof Asset) {
return array("id" => $element->getId(), "path" => $element->getFullPath(), "type" => "asset", "subtype" => $element->getType());
} else {
if ($element instanceof Object_Abstract) {
return array("id" => $element->getId(), "path" => $element->getFullPath(), "type" => "object", "subtype" => $element->geto_Type());
}
}
}
}
示例2: getTreeNodeConfig
/**
* @param Asset $asset
* @return array|string
*/
protected function getTreeNodeConfig($asset)
{
$tmpAsset = array("id" => $asset->getId(), "text" => $asset->getFilename(), "type" => $asset->getType(), "path" => $asset->getFullPath(), "basePath" => $asset->getPath(), "locked" => $asset->isLocked(), "lockOwner" => $asset->getLocked() ? true : false, "elementType" => "asset", "permissions" => array("remove" => $asset->isAllowed("delete"), "settings" => $asset->isAllowed("settings"), "rename" => $asset->isAllowed("rename"), "publish" => $asset->isAllowed("publish"), "view" => $asset->isAllowed("view")));
// set type specific settings
if ($asset->getType() == "folder") {
$tmpAsset["leaf"] = false;
$tmpAsset["expanded"] = $asset->hasNoChilds();
$tmpAsset["iconCls"] = "pimcore_icon_folder";
$tmpAsset["permissions"]["create"] = $asset->isAllowed("create");
} else {
$tmpAsset["leaf"] = true;
$tmpAsset["iconCls"] = "pimcore_icon_" . Pimcore_File::getFileExtension($asset->getFilename());
}
$tmpAsset["qtipCfg"] = array("title" => "ID: " . $asset->getId());
if ($asset->getType() == "image") {
try {
$tmpAsset["qtipCfg"] = array("title" => "ID: " . $asset->getId(), "text" => '<img src="/admin/asset/get-image-thumbnail/id/' . $asset->getId() . '/width/130/aspectratio/true" width="130" />', "width" => 140);
// this is for backward-compatibilty, to calculate the dimensions if they are not there
if (!$asset->getCustomSetting("imageDimensionsCalculated")) {
$asset->save();
}
if ($asset->getCustomSetting("imageWidth") && $asset->getCustomSetting("imageHeight")) {
$tmpAsset["imageWidth"] = $asset->getCustomSetting("imageWidth");
$tmpAsset["imageHeight"] = $asset->getCustomSetting("imageHeight");
}
} catch (Exception $e) {
Logger::debug("Cannot get dimensions of image, seems to be broken.");
}
} else {
if ($asset->getType() == "video") {
try {
if (Pimcore_Video::isAvailable()) {
$tmpAsset["qtipCfg"] = array("title" => "ID: " . $asset->getId(), "text" => '<img src="/admin/asset/get-video-thumbnail/id/' . $asset->getId() . '/width/130/aspectratio/true" width="130" />', "width" => 140);
}
} catch (Exception $e) {
Logger::debug("Cannot get dimensions of video, seems to be broken.");
}
}
}
$tmpAsset["cls"] = "";
if ($asset->isLocked()) {
$tmpAsset["cls"] .= "pimcore_treenode_locked ";
}
if ($asset->getLocked()) {
$tmpAsset["cls"] .= "pimcore_treenode_lockOwner ";
}
return $tmpAsset;
}
示例3: getById
/**
* Static helper to get an asset by the passed id (returned is not the concrete asset like Asset_Folder!)
*
* @param integer $id
* @return Asset
*/
public static function getById($id)
{
$id = intval($id);
if ($id < 1) {
return null;
}
$cacheKey = "asset_" . $id;
try {
$asset = Zend_Registry::get($cacheKey);
if (!$asset) {
throw new Exception("Asset in registry is null");
}
} catch (Exception $e) {
try {
if (!($asset = Pimcore_Model_Cache::load($cacheKey))) {
$asset = new Asset();
$asset->getResource()->getById($id);
$typeClass = "Asset_" . ucfirst($asset->getType());
$typeClass = Pimcore_Tool::getModelClassMapping($typeClass);
if (class_exists($typeClass)) {
$asset = new $typeClass();
Zend_Registry::set($cacheKey, $asset);
$asset->getResource()->getById($id);
Pimcore_Model_Cache::save($asset, $cacheKey);
}
} else {
Zend_Registry::set($cacheKey, $asset);
}
} catch (Exception $e) {
Logger::warning($e);
return null;
}
}
if (!$asset) {
return null;
}
return $asset;
}
示例4: getDataForEditmode
/**
* @see Object_Class_Data::getDataForEditmode
* @param Asset|Document|Object_Abstract $data
* @param null|Object_Abstract $object
* @return array
*/
public function getDataForEditmode($data, $object = null)
{
if ($data) {
$r = array("id" => $data->getId(), "path" => $data->getFullPath());
if ($data instanceof Document) {
$r["subtype"] = $data->getType();
$r["type"] = "document";
} else {
if ($data instanceof Asset) {
$r["subtype"] = $data->getType();
$r["type"] = "asset";
} else {
if ($data instanceof Object_Abstract) {
$r["subtype"] = $data->getO_Type();
$r["type"] = "object";
}
}
}
return $r;
}
return;
}
示例5: allowAssetRelation
/**
*
* Checks if an asset is an allowed relation
* @param Asset $asset
* @return boolean
*/
protected function allowAssetRelation($asset)
{
$allowedAssetTypes = $this->getAssetTypes();
$allowed = true;
if (!$this->getAssetsAllowed()) {
$allowed = false;
} else {
if ($this->getAssetsAllowed() and is_array($allowedAssetTypes) and count($allowedAssetTypes) > 0) {
//check for allowed asset types
foreach ($allowedAssetTypes as $t) {
if (is_array($t) && array_key_exists("assetTypes", $t)) {
$t = $t["assetTypes"];
}
if ($t && is_string($t)) {
$allowedTypes[] = $t;
}
}
if (!in_array($asset->getType(), $allowedTypes)) {
$allowed = false;
}
} else {
//don't check if no allowed asset types set
}
}
\Logger::debug("checked object relation to target asset [" . $asset->getId() . "] in field [" . $this->getName() . "], allowed:" . $allowed);
return $allowed;
}