本文整理汇总了PHP中Media::getEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP Media::getEntity方法的具体用法?PHP Media::getEntity怎么用?PHP Media::getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media::getEntity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMediaItemMarkup
public static function getMediaItemMarkup($mediaId, $userID, $tenantID)
{
$class = new Media($userID, $tenantID);
try {
$media = $class->getEntity($mediaId);
return Display::getMediaMarkup($media);
} catch (Exception $ex) {
// do anything or just ignore if we can't load? Ignoring for now
//echo '<p>unable to load: ' . $ex->getMessage() . '</p>';
return '<p class="hidden">Unable to load media id=' . $mediaId . '<p>';
}
}
示例2: actionAddPlanPicture
public function actionAddPlanPicture()
{
if (isset($_FILES) && count($_FILES) > 0 && ControleurRights::canAddPlans()) {
$plan = new Plan();
$plan = Plan::getEntity($_POST['id_plan']);
// Delete old picture
if ($plan->getMedia_id() != null) {
$old_media = Media::getEntity($plan->getMedia_id());
$old_media->deleteEntity();
}
// Upload new picture
$media_list = ControleurMedia::actionUploadNewMedia($_FILES, $_POST['id_plan'], $plan->getName());
// Save picture to plan
$media = $media_list[0];
$media->setIs_main_media(true);
$media->updateEntity();
$plan->setMedia_id($media->getId());
$plan->updateEntity();
}
}
示例3: Media
$feature = $class->getEntity($id);
$hasImage = false;
if (strtolower($feature["status"]) != "published") {
// if contributor, allow to preview and add preview stripe
if ($user->hasRole("admin", $tenantID) || $user->hasRole("contributor", $tenantID)) {
$preview = "You are previewing a feature that is currently in <strong>" . $feature["status"] . '</strong> status.';
} else {
$errorMsg = "We don't seem to be able to find what you're looking for.";
}
} else {
// don't log page views for unpublished feature: distorts counts
Log::logPageView('feature', $id, '');
}
if (key_exists('coverImage', $feature) && $feature["coverImage"] > 0) {
$class = new Media($userID, $tenantID);
$media = $class->getEntity($feature["coverImage"]);
$hasImage = true;
}
} catch (Exception $ex) {
$errorMsg = "Unable to load requested feature: " . $ex->getMessage();
}
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><?php
echo $siteName . ': ' . $feature["headline"];
?>
示例4: setPicture
/**
* @return Media
*/
public function setPicture()
{
if (isset($this->media_id) && $this->media_id != null) {
$this->picture = Media::getEntity($this->media_id);
} else {
$this->picture = null;
}
return $this;
}
示例5: addMedia
/**
*
* Add media to objectId (which type is objectClass)
* and use prefixColumn (column of objectClass) as filename prefix.
* isMainMedia indicate if the upload picture is the main one of the object
*
* @param string $objectClass
* @param string $objectId
* @param string $prefixColumn
* @param boolean $isMainMedia
*/
private static function addMedia($objectClass, $objectId, $prefixColumn, $isMainMedia)
{
if (isset($_FILES) && count($_FILES) > 0) {
$entity = $objectClass::getEntity($objectId);
// Delete old picture
if ($entity->getMedia_id() != null) {
$old_media = Media::getEntity($entity->getMedia_id());
$old_media->deleteEntity();
}
// Upload new picture
$func = 'get' . ucfirst($prefixColumn);
$media_list = ControleurMedia::actionUploadNewMedia($_FILES, $objectId, $entity->{$func}());
// Save picture to project
$media = $media_list[0];
$media->setIs_main_media($isMainMedia);
$media->updateEntity();
$entity->setMedia_id($media->getId());
$entity->updateEntity();
return $entity;
}
}