示例#1
0
 function show_list_item($item)
 {
     echo '<li>';
     echo '<h4>' . $item->get_value('name') . '</h4>' . "\n";
     echo '<div class="media">' . "\n";
     $displayer_chrome = MediaWorkFactory::displayer_chrome($item, 'default');
     if ($displayer_chrome) {
         $displayer_chrome->set_media_work($item);
         if ($this->params['height']) {
             $displayer_chrome->set_media_height($this->params['height']);
         }
         if ($this->params['width']) {
             $displayer_chrome->set_media_width($this->params['width']);
         }
         $embed_markup = $displayer_chrome->get_html_markup();
         echo $embed_markup;
         echo '</div>' . "\n";
         if ($this->params['show_descriptions'] && $item->get_value('description')) {
             echo '<div class="description">' . $item->get_value('description') . '</div>' . "\n";
         }
         if ($this->params['show_authors'] && $item->get_value('author')) {
             echo '<div class="author">By ' . $item->get_value('author') . '</div>' . "\n";
         }
     } else {
         echo 'Media unavailable.';
     }
     echo '</li>' . "\n";
 }
示例#2
0
		function init($args = array())
		{	
			if(isset($this->params['num_per_page']))
				$this->num_per_page = $this->params['num_per_page'];
			
			// only load javascript and css for integrated items
			if ( !empty($this->request[ $this->query_string_frag.'_id' ]) )
			{
				$media_work = new entity($this->request[ $this->query_string_frag.'_id' ]);
				if ($media_work->get_values() && $media_work->get_value('type') == id_of('av'))
				{
					$head_items = $this->get_head_items();
					$head_items->add_javascript(JQUERY_URL, true);
					
					$this->displayer_chrome = MediaWorkFactory::displayer_chrome($media_work, 'av');
					if ($this->displayer_chrome)
					{
						$this->displayer_chrome->set_module($this);
						$this->displayer_chrome->set_head_items($head_items);
					}
				}
			}
	
			parent::init($args);
		}
示例#3
0
 function delete_entity()
 {
     $media_work = new entity($this->get_value('id'));
     $shim = MediaWorkFactory::shim($media_work);
     if ($shim) {
         $shim->delete_media_work($this);
     }
     parent::delete_entity();
 }
示例#4
0
 function init($id, &$page)
 {
     parent::init($id, $page);
     $this->previewer_modifier = MediaWorkFactory::media_work_previewer_modifier($this->_entity);
     if ($this->previewer_modifier) {
         $this->previewer_modifier->set_previewer($this);
         $this->previewer_modifier->set_head_items($this->admin_page->head_items);
     }
 }
 /**
  * run the rewrite rules
  */
 function run()
 {
     $user = new entity($this->vars['user_id']);
     $media_work = new entity($this->vars['id']);
     $shim = MediaWorkFactory::shim($media_work);
     if ($shim) {
         $shim->finish_actions($media_work, $user);
     }
 }
 function init($args = array())
 {
     if ($this->params['integration_library'] && in_array($this->params['integration_library'], $GLOBALS['UPLOADABLE_MEDIA_WORK_INTEGRATION_LIBRARIES'])) {
         $this->_integration_library = $this->params['integration_library'];
         $this->get_head_items()->add_javascript(REASON_HTTP_BASE_PATH . 'modules/media_import/media_import.js');
         $this->get_head_items()->add_stylesheet(REASON_HTTP_BASE_PATH . 'modules/media_import/media_import.css');
         $this->shim = MediaWorkFactory::shim($this->_integration_library);
     }
     force_secure_if_available();
     parent::init($args);
 }
 function init()
 {
     $this->admin_page->title = 'Batch Import Media';
     if (array_key_exists('integration_library', $this->admin_page->request) && $this->admin_page->request['integration_library']) {
         if (in_array($this->admin_page->request['integration_library'], $GLOBALS['NEW_MEDIA_WORK_INTEGRATION_LIBRARIES'])) {
             $this->integration_library = $this->admin_page->request['integration_library'];
             $this->shim = MediaWorkFactory::shim($this->integration_library);
         } else {
             $this->integration_library = 'invalid_library';
         }
     } elseif (count($GLOBALS['NEW_MEDIA_WORK_INTEGRATION_LIBRARIES']) == 1) {
         $this->integration_library = current($GLOBALS['NEW_MEDIA_WORK_INTEGRATION_LIBRARIES']);
         $this->shim = MediaWorkFactory::shim($this->integration_library);
     }
 }
 function init()
 {
     parent::init();
     $this->admin_page->title = 'Select Thumbnail for Media Work';
     $this->media_work = new entity($this->admin_page->id);
     $this->user = new entity($this->admin_page->user_id);
     // Grab the initial associated image, if it exists
     $es = new entity_selector();
     $es->add_type(id_of('image'));
     $es->add_right_relationship($this->media_work->id(), relationship_id_of('av_to_primary_image'));
     $this->cur_image = current($es->run_one());
     $this->admin_page->head_items->add_javascript(JQUERY_URL, true);
     $this->admin_page->head_items->add_javascript(WEB_JAVASCRIPT_PATH . 'media_image_picker_zencoder.js');
     // fd-slider is a polyfill for the range plasmature type
     $this->admin_page->head_items->add_javascript(REASON_PACKAGE_HTTP_BASE_PATH . 'fd-slider/js/fd-slider.js');
     $this->admin_page->head_items->add_stylesheet(REASON_PACKAGE_HTTP_BASE_PATH . 'fd-slider/css/fd-slider.css');
     $this->shim = MediaWorkFactory::shim($this->media_work);
 }
function reason_iframe_get_displayer($media_work)
{
    $displayer = MediaWorkFactory::media_work_displayer($media_work->get_value('integration_library'));
    if ($displayer) {
        $displayer->set_media_work($media_work);
        $media_file = reason_iframe_get_media_file();
        if ((!$media_work->get_value('integration_library') || $media_work->get_value('integration_library') == 'default') && !empty($media_file)) {
            $media_file_id = $media_file->id();
            $displayer->set_current_media_file($media_file_id);
        }
        if (!empty($_REQUEST['height'])) {
            $size = $_REQUEST['height'];
            if ($size == 'small') {
                $size = MEDIA_WORK_SMALL_HEIGHT;
            } elseif ($size == 'medium') {
                $size = MEDIA_WORK_MEDIUM_HEIGHT;
            } elseif ($size == 'large') {
                $size = MEDIA_WORK_LARGE_HEIGHT;
            } else {
                $size = (int) $_REQUEST['height'];
            }
            $displayer->set_height($size);
        }
        if (!empty($_REQUEST['width'])) {
            $width = (int) $_REQUEST['width'];
            $displayer->set_width($width);
        }
        if (!empty($_REQUEST['autostart']) && $_REQUEST['autostart']) {
            $displayer->set_autostart(true);
        } else {
            $displayer->set_autostart(false);
        }
        if (!empty($_REQUEST['show_controls']) && $_REQUEST['show_controls'] == 'false') {
            $displayer->set_show_controls(false);
        } else {
            $displayer->set_show_controls(true);
        }
    }
    return $displayer;
}
# Grab the media_work's associated group if it has one
$es = new entity_selector();
$es->add_type(id_of('group_type'));
$es->add_right_relationship($media_work->id(), relationship_id_of('av_restricted_to_group'));
$group = current($es->run_one());
$extension = $media_file->get_value('av_type') == 'Video' ? 'mp4' : 'mp3';
# If the user doesn't have access to the media work, header to the "No Access" url
$mwh = new media_work_helper($media_work);
if (!$mwh->user_has_access_to_media()) {
    $username = reason_require_http_authentication();
    if (!$mwh->user_has_access_to_media($username)) {
        // header to the access denied media
        header('Location: http://' . HTTP_HOST_NAME . REASON_HTTP_BASE_PATH . 'modules/av/no_access_message.' . $extension);
        die;
    }
}
# If we make it here, the podcast is safe to provide
$file_url = $media_file->get_value('url');
// ask the shim if we need to do a url hack to allow iTunes to import the file
$shim = MediaWorkFactory::shim($media_work);
if ($shim) {
    if ($shim->requires_extension_for_podcast()) {
        $extra_extension = '/a.' . $extension;
    } else {
        $extra_extension = '';
    }
} else {
    http_response_code(404);
    die;
}
header('Location: ' . $file_url . $extra_extension . '?novar=0');
 private static function _generate_name($orig_filename, $extension, $extra_dir, $media_file, $media_work)
 {
     $index = strrpos($orig_filename, '.');
     $name = substr($orig_filename, 0, $index);
     if ($extra_dir == 'original') {
         $displayer = MediaWorkFactory::media_work_displayer($media_work);
         $displayer->set_media_work($media_work);
         return $name . '_' . $displayer->get_original_filename_hash() . '.' . $extension;
     } else {
         $displayer = MediaWorkFactory::media_work_displayer($media_work);
         $displayer->set_media_work($media_work);
         return $name . '_' . substr($displayer->get_media_file_hash($media_file), 0, 12) . '.' . $extension;
     }
 }
 function get_av_info($media_works_id, $width = 400, $height = 300, $crop_style = "fill")
 {
     $ret = array();
     //the object that gets returned
     $this->media_works_id = $media_works_id;
     $this->width = $width;
     $this->height = $height;
     $this->crop_style = $crop_style;
     $media_work = new entity($this->media_works_id);
     $es = new entity_selector();
     $es->add_type(id_of('image'));
     $es->add_right_relationship($media_works_id, relationship_id_of('av_to_primary_image'));
     $images = $es->run_one();
     $this->img_results = $images;
     if (count($images) > 0) {
         $image = current($images);
         $av_img_url = $this->get_av_img_url($image);
         $ret['av_img_url'] = $av_img_url;
         //set the av_image_alt to the image description
         $ret['av_img_alt'] = $image->get_value('description');
         $ret['av_img_id'] = $image->get_value('id');
     } else {
         /**
          * This is not working
          */
         //get a blank image with a play button blitted into it
         // set the av_image_alt to "play"
         $ret['av_img_url'] = $this->get_watermark_relative_path($this->media_works_type);
         if ($this->use_absolute_urls) {
             $ret['av_img_url'] = '//' . HTTP_HOST_NAME . $ret['av_img_url'];
         }
         $ret['av_img_alt'] = "play";
         $ret['av_img_id'] = "none";
     }
     if ($media_work->get_value('integration_library') && $media_work->get_value('integration_library') != 'default') {
         reason_include_once('classes/media/factory.php');
         $displayer_chrome = MediaWorkFactory::displayer_chrome($media_work, 'default');
         if ($displayer_chrome) {
             $displayer_chrome->set_media_work($media_work);
             $displayer_chrome->set_media_height($height);
             $displayer_chrome->set_media_width($width);
             $ret['av_html'] = $displayer_chrome->get_html_markup();
             $ret['type'] = $media_work->get_value('av_type');
             $ret['format'] = 'HTML5';
         } else {
             // TODO: test this?
             $ret['av_html'] = '<p>Not available.</p>';
             $ret['type'] = $media_work->get_value('av_type');
             $ret['format'] = 'HTML5';
         }
     } else {
         $avd = new reasonAVDisplay();
         $es = new entity_selector();
         $es->add_type(id_of('av_file'));
         $es->add_right_relationship($media_works_id, relationship_id_of('av_to_av_file'));
         $es->set_order('av.media_format ASC, av.av_part_number ASC');
         $results = $es->run_one();
         $this->avf_results = $results;
         $avf = null;
         $taf = array();
         $taf = $this->get_type_and_format();
         $avf = $this->get_avf($taf['type'], $taf['format']);
         $ret['type'] = $taf['type'];
         $ret['format'] = $taf['format'];
         $this->media_works_type = $taf['type'];
         $avd->set_video_dimensions($width, $height);
         $avd->disable_automatic_play_start();
         if (!empty($image)) {
             $avd->set_placard_image($image);
             // This could be an entity, an ID, or a URL string
             //get the image with a play button blitted into it
         }
         $embed_markup = "";
         if ($avf != null) {
             $embed_markup = $avd->get_embedding_markup($avf);
         }
         $ret['av_html'] = $embed_markup;
     }
     return $ret;
 }
示例#13
0
 function get_media_file_url($item)
 {
     $media_work = new entity($item->get_value('work_id'));
     $shim = MediaWorkFactory::shim($media_work->get_value('integration_library'));
     if ($shim) {
         return $shim->get_media_file_url($item, $media_work);
     }
     return false;
 }
示例#14
0
 /**
  * Get the markup for the media section
  * @todo support classic media somehow
  */
 function get_media_section($media_works)
 {
     $class = count($media_works) > 1 ? 'mediaGallery' : 'basicMedia';
     $str = '<ul class="' . $class . '">';
     foreach ($media_works as $media) {
         $str .= '<li>';
         $str .= '<div class="titleBlock">';
         if ($placard_info = $this->get_media_placard_info($media)) {
             $str .= '<img src="' . $placard_info['url'] . '" alt="Placeholder image for ' . reason_htmlspecialchars($media->get_value('name')) . '" class="placard" width="' . $placard_info['width'] . '" height="' . $placard_info['height'] . '" style="display:none;" />';
         }
         $str .= '<div class="mediaName">' . $media->get_value('name') . '</div>';
         $str .= '</div>';
         //$str .= $media->get_value('integration_library').'<br />';
         $displayer_chrome = MediaWorkFactory::displayer_chrome($media, 'default');
         if ($displayer_chrome) {
             $str .= '<div class="mediaDisplay">';
             $displayer_chrome->set_media_work($media);
             if ($height = $this->get_media_display_height()) {
             }
             $displayer_chrome->set_media_height($height);
             if ($width = $this->get_media_display_width()) {
             }
             $displayer_chrome->set_media_width($width);
             //$str .= get_class($displayer_chrome);
             $str .= $displayer_chrome->get_html_markup();
             $str .= '</div>';
         }
         $str .= '</li>';
     }
     $str .= '</ul>';
     return $str;
 }