예제 #1
0
 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
0
 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
0
        $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
0
파일: Skill.php 프로젝트: alexloic/abime
 /**
  * @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
0
 /** 
  * 
  * 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;
     }
 }