Beispiel #1
0
 /**
  * Convert a field value to something renderable.
  *
  * @param  array			The field details
  * @param  mixed			The raw value
  * @param  integer		Position in fieldset
  * @param  ?array			List of fields the output is being limited to (NULL: N/A)
  * @return mixed			Rendered field (tempcode or string)
  */
 function render_field_value($field, $ev, $i, $only_fields)
 {
     if (is_object($ev)) {
         return $ev;
     }
     if ($ev == '') {
         return '';
     }
     require_code('galleries');
     require_code('galleries2');
     require_code('transcoding');
     $ev = transcode_video($ev, 'catalogue_efv_short', 'cv_value', NULL, NULL, NULL);
     $thumb_url = create_video_thumb($ev);
     if (substr($ev, 0, strlen(get_custom_base_url() . '/')) == get_custom_base_url() . '/') {
         $ev = substr($ev, strlen(get_custom_base_url() . '/'));
     }
     if (url_is_local($ev)) {
         $width = 600;
         $height = 400;
         $length = 0;
     } else {
         list($width, $height, $length) = get_video_details(get_custom_file_base() . '/' . rawurldecode($ev), basename($ev));
     }
     return show_gallery_media($ev, $thumb_url, $width, $height, $length);
 }
Beispiel #2
0
/**
 * Take some image/thumbnail info, and if needed make and caches a thumbnail, and return a thumb url whatever the situation.
 *
 * @param  URLPATH		The full URL to the image which will-be/is thumbnailed
 * @param  URLPATH		The URL to the thumbnail (blank: no thumbnail yet)
 * @param  ID_TEXT		The directory, relative to the ocPortal uploads directory, where the thumbnails are stored. MINUS "_thumbs"
 * @param  ID_TEXT		The name of the table that is storing what we are doing the thumbnail for
 * @param  AUTO_LINK		The ID of the table record that is storing what we are doing the thumbnail for
 * @param  ID_TEXT		The name of the table field where thumbnails are saved
 * @param  ?integer		The thumbnail width to use (NULL: default)
 * @return URLPATH		The URL to the thumbnail
 */
function ensure_thumbnail($full_url, $thumb_url, $thumb_dir, $table, $id, $thumb_field_name = 'thumb_url', $thumb_width = NULL)
{
    if (is_null($thumb_width)) {
        $thumb_width = intval(get_option('thumb_width'));
    }
    if (get_option('is_on_gd') == '0' || !function_exists('imagetypes') || $full_url == '') {
        if (url_is_local($thumb_url) && $thumb_url != '') {
            return get_custom_base_url() . '/' . $thumb_url;
        }
        return $thumb_url;
    }
    if ($thumb_url != '') {
        if (url_is_local($thumb_url)) {
            $thumb_path = get_custom_file_base() . '/' . rawurldecode($thumb_url);
            if (!file_exists($thumb_path)) {
                $from = str_replace(' ', '%20', $full_url);
                if (url_is_local($from)) {
                    $from = get_custom_base_url() . '/' . $from;
                }
                if (is_video($from)) {
                    require_code('galleries2');
                    create_video_thumb($full_url, $thumb_path);
                } else {
                    convert_image($from, $thumb_path, intval($thumb_width), -1, -1, false);
                }
            }
            return get_custom_base_url() . '/' . $thumb_url;
        }
        return $thumb_url;
    }
    $url_parts = explode('/', $full_url);
    $i = 0;
    $_file = $url_parts[count($url_parts) - 1];
    $dot_pos = strrpos($_file, '.');
    $ext = substr($_file, $dot_pos + 1);
    if (!is_saveable_image($_file)) {
        $ext = 'png';
    }
    $_file = preg_replace('#[^\\w]#', 'x', substr($_file, 0, $dot_pos));
    $thumb_path = '';
    do {
        $file = rawurldecode($_file) . ($i == 0 ? '' : strval($i));
        $thumb_path = get_custom_file_base() . '/uploads/' . $thumb_dir . '_thumbs/' . $file . '.' . $ext;
        $i++;
    } while (file_exists($thumb_path));
    $thumb_url = 'uploads/' . $thumb_dir . '_thumbs/' . rawurlencode($file) . '.' . $ext;
    if (substr($table, 0, 2) == 'f_' && get_forum_type() == 'ocf') {
        $GLOBALS['FORUM_DB']->query_update($table, array($thumb_field_name => $thumb_url), array('id' => $id), '', 1);
    } else {
        $GLOBALS['SITE_DB']->query_update($table, array($thumb_field_name => $thumb_url), array('id' => $id), '', 1);
    }
    $from = str_replace(' ', '%20', $full_url);
    if (url_is_local($from)) {
        $from = get_custom_base_url() . '/' . $from;
    }
    if (!file_exists($thumb_path)) {
        if (is_video($from)) {
            require_code('galleries2');
            create_video_thumb($full_url, $thumb_path);
        } else {
            convert_image($from, $thumb_path, intval($thumb_width), -1, -1, false);
        }
    }
    return get_custom_base_url() . '/' . $thumb_url;
}
Beispiel #3
0
 /**
  * Standard aed_module edit actualiser.
  *
  * @param  ID_TEXT		The entry being edited
  */
 function edit_actualisation($_id)
 {
     $id = intval($_id);
     $cat = post_param('cat');
     if (can_submit_to_gallery($cat) === false) {
         access_denied('SUBMIT_HERE');
     }
     make_member_gallery_if_needed($cat);
     $this->check_videos_allowed($cat);
     $validated = post_param_integer('validated', 0);
     $title = post_param('title');
     $urls = get_url('url', 'file', 'uploads/galleries' . (get_value('use_gallery_subdirs') == '1' ? '/' . $cat : ''), 0, OCP_UPLOAD_VIDEO, true, 'thumb_url', 'file2');
     if ($urls[0] == '') {
         warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
     }
     $url = $urls[0];
     if (!array_key_exists(1, $urls) || $urls[1] == '') {
         $thumb_url = '';
     } else {
         $thumb_url = $urls[1];
     }
     if (substr($url, 0, 8) != 'uploads/' && $url != '' && is_null(http_download_file($url, 0, false)) && !is_null($GLOBALS['HTTP_MESSAGE_B'])) {
         attach_message($GLOBALS['HTTP_MESSAGE_B'], 'warn');
     }
     if ($thumb_url == '' && $url != '') {
         $thumb_url = create_video_thumb($url);
     }
     if ($thumb_url == '') {
         $rows = $GLOBALS['SITE_DB']->query_select('videos', array('url', 'thumb_url'), array('id' => $id), '', 1);
         $thumb_url = $rows[0]['thumb_url'];
     }
     if ($url == '' || $thumb_url == '') {
         warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
     }
     $comments = post_param('comments');
     $allow_rating = post_param_integer('allow_rating', 0);
     $allow_comments = post_param_integer('allow_comments', 0);
     $notes = post_param('notes', '');
     $allow_trackbacks = post_param_integer('allow_trackbacks', 0);
     list($video_width, $video_height, $video_length) = $this->get_special_video_info();
     $this->donext_type = $cat;
     if ($validated == 1 && $GLOBALS['SITE_DB']->query_value('videos', 'validated', array('id' => $id)) == 0) {
         $submitter = $GLOBALS['SITE_DB']->query_value('videos', 'submitter', array('id' => $id));
         if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'galleries') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'galleries', $cat)) {
             syndicate_described_activity($submitter != get_member() ? 'galleries:ACTIVITY_VALIDATE_VIDEO' : 'galleries:ACTIVITY_ADD_VIDEO', $title == '' ? $urls[2] : $title, '', '', '_SEARCH:galleries:video:' . strval($id), '', '', 'galleries', 1, NULL);
         }
     }
     edit_video($id, $title, $cat, $comments, $url, $thumb_url, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $video_length, $video_width, $video_height, post_param('meta_keywords', ''), post_param('meta_description', ''));
 }