function display_entity()
 {
     $this->start_table();
     $id = $this->_entity->id();
     // Full Size Image
     $full_name = reason_get_image_filename($id);
     $local_full_image_path = PHOTOSTOCK . $full_name;
     if (file_exists($local_full_image_path)) {
         $this->show_item_default('Full Image', '<img src="' . WEB_PHOTOSTOCK . $full_name . '" alt="Full Size Image" />');
     }
     // Thumbnail Image
     $tn_name = reason_get_image_filename($id, 'thumbnail');
     $local_tn_image_path = PHOTOSTOCK . $tn_name;
     if (file_exists($local_tn_image_path)) {
         $this->show_item_default('Thumbnail Image', '<img src="' . WEB_PHOTOSTOCK . $tn_name . '" alt="Thumbnail Image" />');
     }
     // Original Image if we are in the owner site
     $owner = $this->_entity->get_owner();
     if (!empty($owner) && $owner->id() == $this->admin_page->site_id) {
         $original_name = reason_get_image_filename($id, 'original');
         $local_original_image_path = PHOTOSTOCK . $original_name;
         if (file_exists($local_original_image_path)) {
             $this->show_item_default('Hi-Res Image', '<a href="' . WEB_PHOTOSTOCK . $original_name . '">View original image </a>');
         }
     }
     $this->show_item_default('Custom sizes', '<a href="' . carl_make_link(array('cur_module' => 'ImageSizer')) . '">Get this image at a custom size</a>');
     // Everything Else
     $this->show_all_values($this->_entity->get_values());
     $this->end_table();
 }
Example #2
0
 function get_teaser_image_markup()
 {
     $markup_string = '';
     $image = current($this->passed_vars['teaser_image']);
     if (!empty($image)) {
         $markup_string .= '<div class="primaryImage">';
         $markup_string .= '<img src="' . WEB_PHOTOSTOCK . reason_get_image_filename($image->id()) . '" width="' . $image->get_value('width') . '" height="' . $image->get_value('height') . '" alt="' . str_replace('"', "'", $image->get_value('description')) . '"/>';
         $markup_string .= '</div>';
     }
     return $markup_string;
 }
Example #3
0
 function make_enclosure($item, $attr, $value)
 {
     static $mime_map = array('art' => 'image/x-jg', 'bmp' => 'image/x-ms-bmp', 'gif' => 'image/gif', 'ico' => 'image/vnd.microsoft.icon', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'jfif' => 'image/jpeg', 'jfi' => 'image/jpeg', 'jif' => 'image/jpeg', 'jp2' => 'image/jp2', 'j2k' => 'image/jp2', 'pict' => 'image/x-pict', 'pct' => 'image/x-pict', 'pcx' => 'image/x-pcx', 'pic' => 'image/x-pict', 'png' => 'image/png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff');
     $filename = reason_get_image_filename($value, 'thumbnail');
     $url = 'http://' . REASON_HOST . WEB_PHOTOSTOCK . $filename;
     $type = 'image/x-unknown';
     if (!empty($extension) && array_key_exists($extension, $mime_map)) {
         $type = $mime_map[$extension];
     }
     $size = file_exists(PHOTOSTOCK . $filename) ? filesize(PHOTOSTOCK . $filename) : 0;
     return '<' . $attr . ' url="' . $url . '" length="' . $size . '" type="' . $type . '" />' . "\n";
 }
            $xtra = 'id passed to script is not the id of a Reason entity';
        } elseif ($image->get_value('type') != id_of('image')) {
            $xtra = 'id passed to script is not the id of an image';
        } elseif ($image->get_value('state') != 'Live') {
            $xtra = 'image requested is ' . strtolower($image->get_value('state'));
        }
        $xtra .= ' ( Referrer: ' . $_SERVER['HTTP_REFERER'] . ' )';
        trigger_error('Bad image request on image popup script - ' . $xtra);
    }
    $image = null;
}
if (!empty($image)) {
    $GLOBALS['_reason_image_popup_data']['id'] = $id;
    $GLOBALS['_reason_image_popup_data']['title'] = $image->get_value('description') ? $image->get_value('description') : 'Image';
    $GLOBALS['_reason_image_popup_data']['image_exists'] = true;
    $GLOBALS['_reason_image_popup_data']['image_tag'] = '<img src="' . WEB_PHOTOSTOCK . reason_get_image_filename($id) . '" width="' . $image->get_value('width') . '" height="' . $image->get_value('height') . '" border="0" alt="' . htmlentities(strip_tags($image->get_value('description'))) . '" />';
    $GLOBALS['_reason_image_popup_data']['image_caption'] = $image->get_value('content') ? $image->get_value('content') : $image->get_value('description');
    $GLOBALS['_reason_image_popup_data']['image_author'] = $image->get_value('author');
} else {
    $GLOBALS['_reason_image_popup_data']['image_exists'] = false;
    $GLOBALS['_reason_image_popup_data']['title'] = 'Image not found';
}
if (defined('IMAGE_POPUP_TEMPLATE_FILENAME')) {
    $template_path = 'popup_templates/' . IMAGE_POPUP_TEMPLATE_FILENAME;
} else {
    $template_path = 'popup_templates/generic_image_popup_template.php';
}
if (reason_file_exists($template_path)) {
    reason_include($template_path);
} else {
    trigger_error('no template file found for the image popup script (looking for file at ' . $template_path . '; change Reason setting IMAGE_POPUP_TEMPLATE_FILENAME to set the template file)');
Example #5
0
 function get_image($id)
 {
     $this->fix_image_info($id);
     $image = $this->images[$id];
     $img = '<img src="' . $this->web_image_dir . '/' . reason_get_image_filename($id) . '" ';
     if ($image['width'] and $image['height']) {
         $img .= 'width="' . $image['width'] . '" height="' . $image['height'] . '" ';
     }
     $img .= 'alt="' . strip_tags(str_replace('"', "'", $image['description'])) . '" border="0" />';
     return $img;
 }
Example #6
0
/**
 * Gets the full server path of an image.
 * @param mixed $image the ID of an image entity or an image entity object
 * @param string $size the desired scaling of the image: thumbnail/thumb/tn,
 *                     standard/default, or original/full (which is not always
 *                     available)
 * @return string the image file's path, or NULL if an invalid value was given
 *                for $image
 */
function reason_get_image_path($image, $size='standard')
{
	$filename = reason_get_image_filename($image, $size);
	return ($filename) ? PHOTOSTOCK.$filename : null;
}
Example #7
0
 /**
  * Show an image thumbnail
  *
  * Note that this function does not return XHTML; instead it directly outputs it
  * via echo statements. If you want returned XHTML, use get_show_image_html().
  *
  * @param mixed $image An image object, image ID, or array of image values
  * @param boolean $die_without_thumbnail Echo nothing if no thumb available? (default behavior 
  *                                       is to make link to full-sized image if no thumb available)
  * @param boolean $show_popup_link Wrap image in link that pops up image popup?
  * @param boolean $show_description Place the image description (i.e. short caption) below the image?
  * @param string $other_text Text to use instead of image description
  * @param boolean $textonly True sets function into textonly mode, which instead of outputting
  *                          image markup outputs a text description linking to image
  * @param boolean $show_author Output the value of the author field below the description?
  * @param string $link_with_url Wrap the image in a link to this URL instead of to image popup
  * @return void
  *
  * @todo Make a better image markup library!
  */
 function show_image($image, $die_without_thumbnail = false, $show_popup_link = true, $show_description = true, $other_text = '', $textonly = false, $show_author = false, $link_with_url = '')
 {
     if (is_array($image)) {
         $id = $image['id'];
     } elseif (is_object($image)) {
         if ('reasonSizedImage' == get_class($image)) {
             $sizedImageObject = $image;
             $image_entity = $sizedImageObject->get_entity();
             $values = $image_entity->get_values();
             $id = $image_entity->id();
             $image = $values;
         } else {
             $values = $image->get_values();
             $id = $image->id();
             $image = $values;
         }
     } else {
         $id = $image;
         $image = get_entity_by_id($id);
     }
     if (isset($sizedImageObject)) {
         $tn = true;
         $width = $sizedImageObject->get_image_width();
         $height = $sizedImageObject->get_image_height();
         $image_path = $sizedImageObject->get_file_system_path_and_file_of_dest();
         $mod_time = filemtime($image_path);
         $image_url = $sizedImageObject->get_URL() . '?cb=' . $mod_time;
     } else {
         $tn_name = reason_get_image_filename($id, 'tn');
         $fs_name = reason_get_image_filename($id);
         if (file_exists(PHOTOSTOCK . $tn_name)) {
             $tn = true;
             $image_name = $tn_name;
         } elseif (file_exists(PHOTOSTOCK . $fs_name)) {
             if ($die_without_thumbnail) {
                 return;
             }
             $tn = false;
             $image_name = $fs_name;
         } else {
             trigger_error('No thumbail or full sized image found for image id ' . $id);
             return;
         }
         $image_path = PHOTOSTOCK . $image_name;
         list($width, $height) = getimagesize($image_path);
         $mod_time = filemtime($image_path);
         $image_url = WEB_PHOTOSTOCK . $image_name . '?cb=' . $mod_time;
     }
     if (file_exists($image_path)) {
         $full_image_exists = file_exists(PHOTOSTOCK . reason_get_image_filename($id));
         if (!$image['description']) {
             if ($image['keywords']) {
                 $image['description'] = $image['keywords'];
             } else {
                 $image['description'] = $image['name'];
             }
         }
         $window_width = $image['width'] < 340 ? 340 : 40 + $image['width'];
         $window_height = 170 + $image['height'];
         // formerly 130 // 96 works on Mac IE 5
         if (empty($link_with_url)) {
             if (empty($textonly)) {
                 $pre_link = "<a onmouseover=\"window.status = 'view larger image'; return true;\" onmouseout=\"window.status = ''; return true;\" onclick=\"this.href='javascript:void(window.open(\\'" . REASON_IMAGE_VIEWER . "?id=" . $image['id'] . "\\', \\'PopupImage\\', \\'menubar,scrollbars,resizable,width=" . $window_width . ",height=" . $window_height . "\\'))'\" href=\"" . WEB_PHOTOSTOCK . reason_get_image_filename($id) . "?cb=" . filemtime($image_path) . "\">";
             } else {
                 $pre_link = '<a href="' . WEB_PHOTOSTOCK . reason_get_image_filename($id) . '?cb=' . filemtime(PHOTOSTOCK . $image_name) . '">';
             }
         } else {
             $pre_link = '<a href="' . $link_with_url . '">';
         }
         if (empty($textonly)) {
             echo '<div class="tnImage">';
             if (($tn and $show_popup_link and $full_image_exists) || $tn && !empty($link_with_url)) {
                 echo $pre_link;
             }
             // show photo
             echo '<img src="' . $image_url . '" width="' . $width . '" height="' . $height . '" alt="' . reason_htmlspecialchars($image['description']) . '" class="thumbnail" border="0"/>';
             if (($tn and $show_popup_link and $full_image_exists) || $tn && !empty($link_with_url)) {
                 echo '</a>';
             }
             echo '</div>';
         }
         if ($show_description) {
             $desc =& $image['description'];
             if (empty($textonly)) {
                 echo '<div class="tnDesc smallText">';
             } else {
                 echo '<div class="tnDesc">';
             }
             if ($tn and $show_popup_link and $full_image_exists) {
                 echo $pre_link . $desc . '</a>';
             } else {
                 echo $desc;
             }
             echo '</div>';
         }
         if ($other_text) {
             if (empty($textonly)) {
                 echo '<div class="tnDesc smallText">';
             } else {
                 echo '<div class="tnDesc">';
             }
             if ($tn and $show_popup_link and $full_image_exists) {
                 echo $pre_link . $other_text . '</a>';
             } else {
                 echo $other_text;
             }
             echo '</div>';
         }
         if ($show_author and !empty($image['author'])) {
             echo '<div class="tnAuthor smallText">Photo: ' . $image['author'] . '</div>';
         }
     }
 }
Example #8
0
 /**
  * Get information about an image, such as
  * height, width, url, etc.
  *
  * This should be replaced by a new image
  * class that's nicer and cleaner.
  */
 function get_image_data($image)
 {
     $values = $image->get_values();
     $id = $image->id();
     $image = $values;
     $tn_name = reason_get_image_filename($id, 'tn');
     $full_name = reason_get_image_filename($id);
     if (file_exists(PHOTOSTOCK . $tn_name)) {
         $return_array['thumb']['url'] = WEB_PHOTOSTOCK . $tn_name;
         list($return_array['thumb']['width'], $return_array['thumb']['height']) = getimagesize(PHOTOSTOCK . $tn_name);
     }
     if (file_exists(PHOTOSTOCK . $full_name)) {
         $return_array['full']['url'] = WEB_PHOTOSTOCK . $full_name;
         list($return_array['full']['width'], $return_array['full']['height']) = getimagesize(PHOTOSTOCK . $full_name);
     }
     $return_array['description'] = $image['description'];
     return $return_array;
 }