Beispiel #1
0
 function get_markup($events)
 {
     $ret = '<div id="eventsGalleryModule" class="bigList">' . "\n";
     $ret .= '<ul class="events">' . "\n";
     foreach ($events as $event) {
         $ret .= '<li class="event">' . "\n";
         $ret .= '<a href="' . reason_htmlspecialchars($event->get_url()) . '">' . "\n";
         $ret .= '<span class="imageWrap">' . "\n";
         if ($image = $event->get_image()) {
             reason_include_once('classes/sized_image.php');
             $rsi = new reasonSizedImage();
             $rsi->set_id($image->id());
             $rsi->set_width(280);
             $rsi->set_height(200);
             $url = $rsi->get_url();
             $ret .= '<img src="' . htmlspecialchars($url) . '" alt="' . reason_htmlspecialchars(strip_tags($image->get_value('description'))) . '" width="295" height="200" class="primaryImage" />' . "\n";
         }
         $ret .= '</span>' . "\n";
         $ret .= '<span class="info">' . "\n";
         $ret .= '<span class="meta">' . "\n";
         $ret .= '<em class="currency">' . htmlspecialchars($event->temporal_phrase()) . '</em> / ';
         $ret .= '<span class="dates">' . htmlspecialchars($event->date_range_phrase()) . '</span>' . "\n";
         $ret .= '</span><br />' . "\n";
         $ret .= '<span class="name">' . "\n";
         $ret .= '<strong class="title">';
         $ret .= $event->get_main_title($event);
         if ($sub = $event->get_subtitle($event)) {
             $ret .= ':';
         }
         $ret .= '</strong>';
         if (!empty($sub)) {
             $ret .= '<span class="subtitle">' . $sub . '</span>' . "\n";
         }
         $ret .= '</span>' . "\n";
         $ret .= '</span>' . "\n";
         $ret .= '</a>' . "\n";
         $ret .= '</li>' . "\n";
     }
     $ret .= '</ul>' . "\n";
     $ret .= '</div>' . "\n";
     return $ret;
 }
Beispiel #2
0
 function get_images_section()
 {
     $str = '';
     $str .= '<ul>';
     foreach ($this->passed_vars['item_images'] as $image) {
         $str .= '<li class="imageChunk">';
         $rsi = new reasonSizedImage();
         $rsi->set_id($image->id());
         $rsi->set_width(400);
         // Uncomment if you want to force a height or crop
         //$rsi->set_height(300);
         //$rsi->set_crop_style('fill');
         ob_start();
         show_image($rsi, false, true, true, '');
         $str .= ob_get_contents();
         ob_end_clean();
         $str .= '</li>';
     }
     $str .= '</ul>';
     return $str;
 }
Beispiel #3
0
 function show_list_item($item)
 {
     if ($item->get_value('content')) {
         $caption = $item->get_value('content');
     } else {
         $caption = $item->get_value('description');
     }
     if ($this->params['width'] || $this->params['height']) {
         $rsi = new reasonSizedImage();
         $rsi->set_id($item->id());
         if ($this->params['height']) {
             $rsi->set_height($this->params['height']);
         }
         if ($this->params['width']) {
             $rsi->set_width($this->params['width']);
         }
         if ($this->params['crop']) {
             $rsi->set_crop_style($this->params['crop']);
         }
         $image_url = $rsi->get_url();
         $width = $rsi->get_image_width();
         $height = $rsi->get_image_height();
     } else {
         $image_url = reason_get_image_url($item) . '?cb=' . urlencode($item->get_value('last_modified'));
         $width = $item->get_value('width');
         $height = $item->get_value('height');
     }
     echo '<li>';
     if (empty($this->textonly)) {
         echo '<img src="' . $image_url . '" width="' . $width . '" height="' . $height . '" alt="' . htmlspecialchars(strip_tags($item->get_value('description')), ENT_QUOTES) . '" />';
         if ($this->params['show_captions']) {
             echo '<div class="caption">' . $caption . '</div>' . "\n";
         }
         if ($this->params['show_authors'] && $item->get_value('author')) {
             echo '<div class="author">Photo: ' . $item->get_value('author') . '</div>' . "\n";
         }
     } else {
         echo '<a href="' . $image_url . '" title="View image">' . $caption . '</a>' . "\n";
     }
     echo '</li>' . "\n";
 }
 function get_teaser_image_markup()
 {
     $markup_string = '';
     $image = $this->passed_vars['teaser_image'];
     if (!empty($image)) {
         $markup_string .= '<div class="teaserImage">';
         if (is_array($image)) {
             $image = reset($image);
         }
         $rsi = new reasonSizedImage();
         $rsi->set_id($image->id());
         $rsi->set_width(600);
         $rsi->set_height(600);
         $rsi->set_crop_style('fill');
         ob_start();
         show_image($rsi, true, false, false, '');
         $markup_string .= ob_get_contents();
         ob_end_clean();
         $markup_string .= '</div>';
     }
     return $markup_string;
 }
 /**
  * Returns an array of image info for the given images.
  * @param string $crop Crop style for the reason sized image. May be either 'fill' or 'fit'
  * @return array Each element of the array is an associative array with the folowing keys: description, height, width, url
  */
 function getSlideshowImageInfo()
 {
     $crop = $this->getParam('crop', '');
     $imageInfo = array();
     foreach ($this->images as $image) {
         $imgDescription = $image->get_value('description');
         $imgContent = $image->get_value('content');
         $imgAuthor = $image->get_value('author');
         $imgHeight = $image->get_value('height');
         $imgWidth = $image->get_value('width');
         if (0 != $this->maxHeight || 0 != $this->maxWidth) {
             $rsi = new reasonSizedImage();
             $rsi->set_id($image->id());
             $rsi->set_width($this->maxWidth);
             $rsi->set_height($this->maxHeight);
             if (!empty($crop)) {
                 $rsi->set_crop_style($crop);
             }
             $imgUrl = $rsi->get_url();
             $imgHeight = $rsi->get_image_height();
             $imgWidth = $rsi->get_image_width();
         } else {
             $imgUrl = reason_get_image_url($image);
         }
         $imageInfo[] = array('description' => $imgDescription, 'content' => $imgContent, 'author' => $imgAuthor, 'height' => $imgHeight, 'width' => $imgWidth, 'url' => $imgUrl);
     }
     if (count($imageInfo) == 0) {
         trigger_error("No images set for this slideshow");
     }
     return $imageInfo;
 }
		/**
		 * Returns an array of image info for the given images.
		 * @param array $images array of image entities
		 * @param string $crop Crop style for the reason sized image. May be either 'fill' or 'fit'
		 * @param int $max_height The maximum height of the slideshow
		 * @param int $max_width The maximum width of the slideshow
		 * @return array Each element of the array is an associative array with the folowing keys: description, height, width, url
		 */
		function get_slideshow_images_info($images, $crop, $max_height, $max_width)
		{
			$images_info = array();
			foreach ($images as $image) 
			{
				$img_description = $image->get_value('description');
				$img_content = $image->get_value('content');
				$img_author = $image->get_value('author');
				$img_height = $image->get_value('height');
				$img_width = $image->get_value('width');
				
				//Check if making a reason sized image is necessary.
				//if ($img_height <= $max_height && $img_width <= $max_width && !$this->params['force_image_enlargement'])
				//{
				//	$img_url = reason_get_image_url($image);
				//}
				if (0 != $this->params['height'] or 0 != $this->params['width'])
				{
					$rsi = new reasonSizedImage();
					$rsi->set_id($image->id());
					$rsi->set_width($max_width);
					$rsi->set_height($max_height);
					//$rsi->allow_enlarge($this->params['force_image_enlargement']);
					if (!empty($crop)) $rsi->set_crop_style($crop);
					$img_url = $rsi->get_url();
					$img_height = $rsi->get_image_height();
					$img_width = $rsi->get_image_width();
				}
				else
				{
					$img_url = reason_get_image_url($image);
				}
				$images_info[] = array('description' => $img_description, 'content' => $img_content, 'author' => $img_author, 'height' => $img_height, 'width' => $img_width, 'url' => $img_url);
			}
			return $images_info;
		}
Beispiel #7
0
		function show_child_page($child,$counter,$even_odd)
		{
			/* If the page has a link name, use that; otherwise, use its name */
			$page_name = $this->get_page_name($child);
			$title_attr = '';
			if( $page_name != $child->get_value('name') )
			{
				$title_attr = ' title="'.reason_htmlspecialchars(strip_tags($child->get_value('name')),ENT_QUOTES).'"';
			}
			$page_name = strip_tags($page_name,'<span><strong><em>');
			$link = $this->get_page_link($child);
			$classes = array('number'.$counter, $even_odd);
			$uname = '';
			if($child->get_value( 'unique_name' ))
			{
				$classes[] = 'uname-'.reason_htmlspecialchars($child->get_value( 'unique_name' ));
			}
			if($child->get_value('url'))
			{
				$classes[] = 'jump';
			}
				
			echo '<li class="'.implode(' ',$classes).'">';
			
			if($this->params['provide_az_links'] && array_key_exists($child->id(),$this->az))
			{
				echo '<a name="child_'.$this->az[$child->id()].'"></a>';
			}
			$image_markup = '';
			if($this->params['provide_images'])
			{
				$image = $this->get_page_image($child->id());
				
				if(!empty($image))
				{
					if($this->params['thumbnail_width'] != 0 or $this->params['thumbnail_height'] != 0)
					{
						$rsi = new reasonSizedImage();
						if(!empty($rsi))
						{
							$rsi->set_id($image->id());
							if($this->params['thumbnail_width'] != 0)
							{
								$rsi->set_width($this->params['thumbnail_width']);
							}
							if($this->params['thumbnail_height'] != 0)
							{
								$rsi->set_height($this->params['thumbnail_height']);
							}
							if($this->params['thumbnail_crop'] != '')
							{
								$rsi->set_crop_style($this->params['thumbnail_crop']);
							}
							if(!$this->params['html5'])
								$image_markup = get_show_image_html($rsi, true, false, false, '' , '', false, $link);
							else
								$image_markup = get_show_image_html($rsi, true, false, false, '' , '', false );
						}
					}
					else
					{
						if(!$this->params['html5'])
							$image_markup = get_show_image_html( $image->id(), true, false, false, '' , '', false, $link );
						else
							$image_markup = get_show_image_html( $image->id(), true, false, false, '' , '', false );
					}
				}
				if(!$this->params['html5'])
					echo $image_markup;
			}
			if($this->params['description_part_of_link'])
			{
				$element = $this->params['html5'] ? 'h4' : 'strong';
				echo '<a href="'.$link.'"'.$title_attr.'>';
				if($this->params['html5'])
					echo $image_markup;
				echo '<'.$element.'>'.$page_name.'</'.$element.'>';
				if(!$this->params['html5'])
					echo '<br />';
				if ( $child->get_value( 'description' ))
				{
					$element = $this->params['html5'] ? 'div' : 'span';
					echo "\n".'<'.$element.' class="childDesc">'.$child->get_value( 'description' ).'</'.$element.'>';
				}
				echo '</a>';
			}
			else
			{
				echo '<h4><a href="'.$link.'"'.$title_attr.'>'.$page_name.'</a></h4>';
				if ( $child->get_value( 'description' ))
				{
					echo "\n".'<div class="childDesc">'.$child->get_value( 'description' ).'</div>';
				}
			}
			echo '</li>'."\n";
		}
Beispiel #8
0
 /**
  * use the image id to get a url to a sized image
  * @param $id image id of image to be sized
  * @param $crop_style how to fill the rectangle containing the
  *        image:  fill or fit
  * @return the url to the sized image
  */
 function get_image_url_and_alt($id, $crop_style = "fill")
 {
     $width = $this->width;
     $height = $this->height;
     $rsi = new reasonSizedImage();
     $rsi->set_id($id);
     $rsi->set_width($width);
     $rsi->set_height($height);
     $rsi->set_crop_style($crop_style);
     $ret = $rsi->get_url_and_alt();
     return $ret;
 }
Beispiel #9
0
		function get_primary_image( $item )
		{
			if(empty($this->parent->textonly))
			{
				$item->set_env('site_id',$this->parent->site_id);
				$images = $item->get_left_relationship( relationship_id_of('av_to_primary_image') );
				if(!empty($images))
				{
					$image = current($images);
					if($this->params['thumbnail_width'] != 0 or $this->params['thumbnail_height'] != 0)
					{
						$rsi = new reasonSizedImage();
						if(!empty($rsi))
						{
							$rsi->set_id($image->id());
							if($this->params['thumbnail_width'] != 0)
							{
								$rsi->set_width($this->params['thumbnail_width']);
							}
							if($this->params['thumbnail_height'] != 0)
							{
								$rsi->set_height($this->params['thumbnail_height']);
							}
							if($this->params['thumbnail_crop'] != '')
							{
								$rsi->set_crop_style($this->params['thumbnail_crop']);
							}
							$image = $rsi;
						}
					}
					
					$die_without_thumbnail = true;
					$show_popup_link = false;
					$show_description = false;
					$additional_text = '';
					if(empty($this->request[ $this->query_string_frag.'_id' ]) || $this->request[ $this->query_string_frag.'_id' ] != $item->id() )
					{
						$link = $this->construct_link($item);
					}
					else
					{
						$link = '';
					}
					
					show_image( $image, $die_without_thumbnail, $show_popup_link, $show_description, $additional_text, $this->parent->textonly, false, $link );
				}
			}
		}
Beispiel #10
0
 function show_image($image, $thumbnail = true)
 {
     if ($thumbnail) {
         if (0 != $this->params['thumbnail_height'] or 0 != $this->params['thumbnail_width']) {
             $rsi = new reasonSizedImage();
             $rsi->set_id($image->id());
             if (0 != $this->params['thumbnail_height']) {
                 $rsi->set_height($this->params['thumbnail_height']);
             }
             if (0 != $this->params['thumbnail_width']) {
                 $rsi->set_width($this->params['thumbnail_width']);
             }
             if ('' != $this->params['thumbnail_crop']) {
                 $rsi->set_crop_style($this->params['thumbnail_crop']);
             }
             $width = $rsi->get_image_width();
             $height = $rsi->get_image_height();
             $image_url = $rsi->get_url();
             $image_path = $rsi->get_file_system_path_and_file_of_dest();
         } else {
             $image_path = reason_get_image_path($image, 'tn');
             $image_url = reason_get_image_url($image, 'tn');
             if (!file_exists($image_path)) {
                 $image_path = reason_get_image_path($image);
                 $image_url = reason_get_image_url($image);
             }
             list($width, $height) = getimagesize($image_path);
         }
         $class = 'thumbnail';
     } elseif (!$thumbnail) {
         if (0 != $this->params['height'] or 0 != $this->params['width']) {
             $rsi = new reasonSizedImage();
             $rsi->set_id($image->id());
             if (0 != $this->params['height']) {
                 $rsi->set_height($this->params['height']);
             }
             if (0 != $this->params['width']) {
                 $rsi->set_width($this->params['width']);
             }
             if ('' != $this->params['crop']) {
                 $rsi->set_crop_style($this->params['crop']);
             }
             $width = $rsi->get_image_width();
             $height = $rsi->get_image_height();
             $image_url = $rsi->get_url();
             $image_path = $rsi->get_file_system_path_and_file_of_dest();
         } else {
             $image_path = reason_get_image_path($image);
             list($width, $height) = getimagesize($image_path);
             $image_url = reason_get_image_url($image);
         }
         $class = 'mainImage';
     }
     if (file_exists($image_path)) {
         $alt = $image->get_value('description');
         if (!$alt) {
             $alt = $image->get_value('keywords');
             if (!$alt) {
                 $alt = $image->get_value('name');
             }
         }
         $mod_time = filemtime($image_path);
         return $this->show_image_markup($image_url, $height, $width, $alt, $class, $mod_time);
     } else {
         return false;
     }
 }
Beispiel #11
0
	/**
	 * Get a teaser image for a given event
	 * @param mixed $event_id Event ID or Event object
	 * @param string $link
	 * @return string html
	 * @todo move into a markup class
	 */
	function get_teaser_image_html($event_id, $link = '')
	{
		if(empty($this->params['show_images']))
			return '';
		
		if(is_object($event_id))
			$event_id = $event_id->id();
		
		static $image_cache = array();
		if(!array_key_exists($event_id, $image_cache))
		{
			$es = new entity_selector();
        	$es->description = 'Selecting images for event';
        	$es->add_type( id_of('image') );
        	$es->add_right_relationship( $event_id, relationship_id_of('event_to_image') );
        	$es->add_rel_sort_field($event_id, relationship_id_of('event_to_image'));
        	$es->set_order('rel_sort_order ASC');
        	$es->set_num(1);
        	$images = $es->run_one();
        	if(!empty($images))
        	{
        		$image_cache[$event_id] = current($images);
        	}
        	elseif($image = $this->_get_list_thumbnail_default_image())
        	{
        		$image_cache[$event_id] = $image;
        	}
        	else
        	{
        		$image_cache[$event_id] = NULL;
        	}
        }

        if(!empty($image_cache[$event_id]))
        {
        	if($this->params['list_thumbnail_width'] || $this->params['list_thumbnail_height'])
        	{
        		$rsi = new reasonSizedImage;
        		$rsi->set_id($image_cache[$event_id]->id());
        		if(0 != $this->params['list_thumbnail_height']) $rsi->set_height($this->params['list_thumbnail_height']);
				if(0 != $this->params['list_thumbnail_width']) $rsi->set_width($this->params['list_thumbnail_width']);
				if('' != $this->params['list_thumbnail_crop']) $rsi->set_crop_style($this->params['list_thumbnail_crop']);
				return get_show_image_html( $rsi, true, false, false, '', $this->textonly, false, $link );
        	}
        	else
        	{
        		return get_show_image_html( $image_cache[$event_id], true, false, false, '', $this->textonly, false, $link );
        	}
        }
	}
/**
* A test function for testing _imagemagick_crop_image.  It allows
* you to test several cases quickly.
*/
function im_resize_images()
{
    global $d;
    $img_ids = explode(",", $d['image_id']);
    $width = (int) $d['w'];
    $height = (int) $d['h'];
    $crop_style = $d['crop_style'];
    $target = array();
    $source = array();
    $url = array();
    foreach ($img_ids as $id) {
        $rsi = new reasonSizedImage();
        $rsi->set_id($id);
        $rsi->set_width($width);
        $rsi->set_height($height);
        $rsi->set_crop_style($crop_style);
        $target[] = $rsi->_get_path();
        $entity = new entity($id);
        $source[] = reason_get_image_path($entity, 'standard');
        $url[] = $rsi->_get_url();
    }
    //	print_r($target);
    //	pray($source);
    //	pray($url);
    for ($i = 0; $i < count($source); $i++) {
        _imagemagick_crop_image($width, $height, $source[$i], $target[$i], false);
    }
    $str = "";
    for ($i = 0; $i < count($url); $i++) {
        $str .= "" . $url[$i] . ",";
    }
    $str = trim($str, ",");
    echo $str;
    //		_imagemagick_crop_image($nw,$nh,$source,$target,false);
    //	resize_images();
}
 private function _get_poster_image_url()
 {
     $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'));
     $results = $es->run_one();
     if (!empty($results)) {
         reason_include_once('classes/sized_image.php');
         $primary_image = current($results);
         $rsi = new reasonSizedImage();
         $rsi->set_id($primary_image->id());
         $rsi->set_height($this->_get_closest_size($this->get_embed_height(), array(240, 360, 480)));
         $rsi->allow_enlarge(false);
         return $rsi->get_url();
     } else {
         return false;
     }
 }
 /**
  * If there is no image this is giving us a mess of an image with a huge icon.
  */
 function get_av_img_url($image)
 {
     $width = $this->width;
     $height = $this->height;
     $crop_style = $this->crop_style;
     $id = $image->get_value('id');
     $rsi = new reasonSizedImage();
     $rsi->set_id($id);
     $rsi->set_width($width);
     $rsi->set_height($height);
     $rsi->set_crop_style($crop_style);
     $watermark = $this->get_watermark_absolute_path($this->media_works_type);
     $options = array();
     $options['horizontal'] = "center";
     $options['vertical'] = "center";
     $rsi->set_blit($watermark, $options);
     $rsi->use_absolute_urls($this->use_absolute_urls);
     $url = $rsi->get_url();
     return $url;
 }
 /**
  * Get HTML to display the sized image and its url at the top of the given form
  * @param object disco form
  * @return string HTML to display
  */
 function pre_show_disco(&$disco)
 {
     if ($disco->has_errors()) {
         return '';
     }
     if ($image = $this->_get_image()) {
         $unsized_width = $image->get_value('width');
         $unsized_height = $image->get_value('height');
         $sized_width = $disco->get_value('width');
         $sized_height = $disco->get_value('height');
         if (empty($sized_width) && empty($sized_height) || $unsized_width == $sized_width && $unsized_height == $sized_height) {
             $showing_normal_size = true;
             $url = reason_get_image_url($image);
         } else {
             $showing_normal_size = false;
             $rsi = new reasonSizedImage();
             $server_path = REASON_SIZED_IMAGE_CUSTOM_DIR;
             $web_path = REASON_SIZED_IMAGE_CUSTOM_DIR_WEB_PATH;
             $rsi->set_paths($server_path, $web_path);
             $rsi->set_id($image->id());
             if (!empty($sized_width)) {
                 $rsi->set_width($sized_width);
             }
             if (!empty($sized_height)) {
                 $rsi->set_height($sized_height);
             }
             if ($disco->get_value('crop')) {
                 $rsi->set_crop_style($disco->get_value('crop'));
             }
             $url = $rsi->get_url();
         }
         $ret = '<div class="preview">' . "\n";
         $ret .= '<div class="image"><img src="' . htmlspecialchars($url) . '" alt="Image sized to ' . ($sized_width ? $sized_width : 'auto') . ' by ' . ($sized_height ? $sized_height : 'auto') . ' pixels" /></div>' . "\n";
         if ($showing_normal_size) {
             $ret .= '<div class="normalSizeNotice smallText">(This is the standard size of this image.)</div>' . "\n";
         } else {
             $ret .= '<div class="url"><div class="label"><p>To use this image at this size:</p><ol><li>copy this web address</li><li>paste it into the "image at web address" tab in the "insert image" dialog box.</li></ol></div><input type="text" value="' . htmlspecialchars($url) . '" size="50" /></div>' . "\n";
         }
         $ret .= '</div>' . "\n";
         if (!$showing_normal_size) {
             $ret .= '<h4 class="tryAgainHeading">Try another size</h4>' . "\n";
         }
         return $ret;
     }
 }
 function run()
 {
     $die = isset($this->die_without_thumbnail) ? $this->die_without_thumbnail : false;
     $popup = isset($this->show_popup_link) ? $this->show_popup_link : true;
     $desc = isset($this->description) ? $this->description : true;
     $text = isset($this->additional_text) ? $this->additional_text : "";
     echo '<div class="imageSidebarModule">' . "\n";
     if (!empty($this->textonly)) {
         echo '<h3>Images</h3>' . "\n";
     }
     $even_odd = 'odd';
     foreach ($this->images as $id => $image) {
         $show_text = $text;
         if (!empty($this->show_size)) {
             $show_text .= '<br />(' . $image->get_value('size') . ' kb)';
         }
         echo '<div class="imageChunk ' . $this->get_api_class_string() . ' ' . $even_odd . '">';
         if ($this->params['thumbnail_width'] != 0 or $this->params['thumbnail_height'] != 0) {
             $rsi = new reasonSizedImage();
             if (!empty($rsi)) {
                 $rsi->set_id($image->id());
                 if ($this->params['thumbnail_width'] != 0) {
                     $rsi->set_width($this->params['thumbnail_width']);
                 }
                 if ($this->params['thumbnail_height'] != 0) {
                     $rsi->set_height($this->params['thumbnail_height']);
                 }
                 if ($this->params['thumbnail_crop'] != '') {
                     $rsi->set_crop_style($this->params['thumbnail_crop']);
                 }
                 $image = $rsi;
             }
         }
         if ($this->params['caption_flag'] == false) {
             show_image($image, $die, $popup, false, $show_text, $this->textonly, false, $this->get_image_url($image));
         } else {
             show_image($image, $die, $popup, $desc, $show_text, $this->textonly, false, $this->get_image_url($image));
         }
         echo "</div>\n";
         $even_odd = $even_odd == 'even' ? 'odd' : 'even';
     }
     echo '</div>' . "\n";
 }
Beispiel #17
0
 /**
  * returns the url to the sized image
  * @param $id image id of image to be sized
  * @param $crop_style how to size the image in the new wxh, fill or fit
  * @return The url to the sized image
  */
 function get_image_url_and_alt($id, $crop_style = "fill")
 {
     $width = $this->params['width'];
     $height = $this->params['height'];
     $rsi = new reasonSizedImage();
     $rsi->set_id($id);
     $rsi->set_width($width);
     $rsi->set_height($height);
     $rsi->set_crop_style($crop_style);
     $rsi->use_absolute_urls($this->params['absolute_urls']);
     $ret = $rsi->get_url_and_alt();
     return $ret;
 }
Beispiel #18
0
 function run()
 {
     if ($this->params['previous_next']) {
         $siblings = $this->_get_previous_next($this->siblings);
     } else {
         $siblings = $this->siblings;
     }
     $classes = array('siblingList');
     if ($this->params['provide_images']) {
         $classes[] = 'siblingListWithImages';
     }
     if ($this->params['previous_next']) {
         $classes[] = 'prevNext';
     }
     echo '<div class="siblingsModule">' . "\n";
     if ($this->params['use_parent_title_as_header']) {
         echo '<h3>' . $this->parent_page->get_value('name') . '</h3>' . "\n";
     }
     echo '<ul class="' . implode(' ', $classes) . '">' . "\n";
     $counter = 1;
     $even_odd = 'odd';
     foreach ($siblings as $key => $sibling) {
         $classes = array('number' . $counter, $even_odd);
         $uname = '';
         if ($sibling->get_value('unique_name')) {
             $classes[] = 'uname-' . reason_htmlspecialchars($sibling->get_value('unique_name'));
         }
         /* If the page has a link name, use that; otherwise, use its name */
         $page_name = $sibling->get_value('link_name') ? $sibling->get_value('link_name') : $sibling->get_value('name');
         $image_html = '';
         $is_current_page = false;
         if ($this->parent->cur_page->id() == $sibling->id()) {
             $classes[] = 'currentPage';
             $is_current_page = true;
         }
         $link = '';
         if (!$is_current_page) {
             /* Check for a url (that is, the page is an external link); otherwise, use its relative address */
             if ($sibling->get_value('url')) {
                 $link = $sibling->get_value('url');
                 $classes[] = 'jump';
             } else {
                 $link = '../' . $sibling->get_value('url_fragment') . '/';
                 if (!empty($this->parent->textonly)) {
                     $link .= '?textonly=1';
                 }
                 //pray($this->parent->site_info);
                 //$base_url = $this->parent->site_info[ 'base_url' ];
                 //$link = '/'.$base_url.$this->get_nice_url( $child->id() ).'/';
             }
         }
         if ($this->params['provide_images']) {
             $image = $this->get_page_image($sibling->id());
             if (!empty($image)) {
                 if ($this->params['thumbnail_width'] != 0 or $this->params['thumbnail_height'] != 0) {
                     $rsi = new reasonSizedImage();
                     if (!empty($rsi)) {
                         $rsi->set_id($image->id());
                         if ($this->params['thumbnail_width'] != 0) {
                             $rsi->set_width($this->params['thumbnail_width']);
                         }
                         if ($this->params['thumbnail_height'] != 0) {
                             $rsi->set_height($this->params['thumbnail_height']);
                         }
                         if ($this->params['thumbnail_crop'] != '') {
                             $rsi->set_crop_style($this->params['thumbnail_crop']);
                         }
                         $image_html = get_show_image_html($rsi, true, false, false, '', '', false, $link);
                     }
                 } else {
                     $image_html = get_show_image_html($image->id(), true, false, false, '', '', false, $link);
                 }
             }
         }
         if (!$is_current_page) {
             if ('previous' == $key || 'next' == $key) {
                 $classes[] = $key;
             }
             echo '<li class="' . implode(' ', $classes) . '">';
             if (!empty($prevnext)) {
                 echo '<strong>' . ucfirst($key) . ':</strong> ';
             }
             echo $image_html;
             echo '<a href="' . $link . '">' . $page_name . '</a>';
             /* if ( $sibling->get_value( 'description' ))
             			echo "\n".'<div class="smallText">'.$sibling->get_value( 'description' ).'</div>'; */
             echo "</li>\n";
         } else {
             echo '<li class="' . implode(' ', $classes) . '">';
             echo $image_html;
             echo '<strong>' . $page_name . '</strong>';
             echo '</li>' . "\n";
         }
         $counter++;
         if ($even_odd == 'even') {
             $even_odd = 'odd';
         } else {
             $even_odd = 'even';
         }
     }
     echo '</ul>' . "\n";
     echo '</div>' . "\n";
 }
Beispiel #19
0
 /**
  * Modify the head items of a Reason page
  *
  * This is the primary (and simplest) way for a theme customizer to affect the look of a site.
  *
  * @param object $head_items
  * @return void
  */
 public function modify_head_items($head_items)
 {
     $data = $this->get_customizaton_data();
     if (!empty($data)) {
         $css = '';
         if (!empty($data->background_color)) {
             $css .= 'body{background-color:#' . $data->background_color . ';}';
         }
         if (!empty($data->text_color)) {
             $css .= 'body{color:#' . $data->text_color . ';}';
         }
         if (!empty($data->banner_font)) {
             $css .= '#banner,.banner{font-family:"' . $data->banner_font . '";}';
         }
         if (!empty($data->banner_image_id)) {
             $image = new entity($data->banner_image_id);
             if ($image->get_values() && $image->get_value('type') == id_of('image')) {
                 $rsi = new reasonSizedImage();
                 $rsi->set_id($data->banner_image_id);
                 $rsi->set_width(1680);
                 $rsi->set_height(205);
                 $css .= '#banner,.banner{background-image:url("' . $rsi->get_url() . '");}';
             } else {
                 trigger_error('Banner image ID in theme customizer not valid');
             }
         }
         $head_items->add_head_item('style', array('type' => 'text/css'), $css);
     }
 }
/**
 * Get information about the placard image to use for a given media file
 * @param object $media_file
 * @param mixed $media_work entity object or null. If null, media work will be found
 * @return array('image'=>entity,'url'=>sized url,'width' =>width,'height'=>height)
 */
function reason_get_media_placard_image_info($media_file,$media_work = null)
{
	if(empty($media_file))
	{
		trigger_error('reason_get_media_placard_image_info(0 requires a media file as the first argument');
		return null;
	}
	
	if($media_file->get_value('av_type') == 'Audio')
		return null;
	
	if(empty($media_work))
	{
		$es = new entity_selector();
		$es->add_type(id_of('av'));
		$es->add_left_relationship($media_file->id(),relationship_id_of('av_to_av_file'));
		$es->set_num(1);
		$works = $es->run_one();
		if(!empty($works))
			$media_work = current($works);
		else
			return null;
	}
	$es = new entity_selector();
	$es->add_type(id_of('image'));
	$es->add_right_relationship($media_work->id(),relationship_id_of('av_to_primary_image'));
	$es->set_num(1);
	$images = $es->run_one();
	if(!empty($images))
	{
		$image = current($images);
		$rsi = new reasonSizedImage();
		$rsi->set_id($image->id());
		$width = 480;
		$height = 320;
		if($media_file->get_value('width') && $media_file->get_value('height'))
		{
			$width = $media_file->get_value('width');
			$height = $media_file->get_value('height');
		}
		$rsi->set_width($width);
		$rsi->set_height($height);
		$rsi->set_crop_style('fill');
		$image_url = $rsi->get_url();
		return array(
			'image' => $image,
			'url' => $image_url,
			'width' => $rsi->get_image_width(),
			'height' => $rsi->get_image_height()
		);
	}
	return null;
}
 function get_image_markup($page)
 {
     $image_markup = '';
     if ($this->params['provide_images']) {
         $image = $this->get_page_image($page->id());
         if (!empty($image)) {
             if ($this->params['thumbnail_width'] != 0 or $this->params['thumbnail_height'] != 0) {
                 $rsi = new reasonSizedImage();
                 if (!empty($rsi)) {
                     $rsi->set_id($image->id());
                     if ($this->params['thumbnail_width'] != 0) {
                         $rsi->set_width($this->params['thumbnail_width']);
                     }
                     if ($this->params['thumbnail_height'] != 0) {
                         $rsi->set_height($this->params['thumbnail_height']);
                     }
                     if ($this->params['thumbnail_crop'] != '') {
                         $rsi->set_crop_style($this->params['thumbnail_crop']);
                     }
                     $image_markup = get_show_image_html($rsi, true, false, false, '', '', false);
                 }
             } else {
                 $image_markup = get_show_image_html($image->id(), true, false, false, '', '', false);
             }
         }
     }
     return $image_markup;
 }
Beispiel #22
0
 /**
  * @return mixed a reasonSizedImage object or the image id if no sizing required
  */
 function get_sized_image($image_id)
 {
     if ($this->params['thumbnail_width'] != 0 or $this->params['thumbnail_height'] != 0) {
         $rsi = new reasonSizedImage();
         $rsi->set_id($image_id);
         if ($this->params['thumbnail_width'] != 0) {
             $rsi->set_width($this->params['thumbnail_width']);
         }
         if ($this->params['thumbnail_height'] != 0) {
             $rsi->set_height($this->params['thumbnail_height']);
         }
         if ($this->params['thumbnail_crop'] != '') {
             $rsi->set_crop_style($this->params['thumbnail_crop']);
         }
         return $rsi;
     }
     return $image_id;
 }