Пример #1
0
/**
 * Load file data from the database
 * 
 * @param array $pFileHash Contains all file information
 * @param array $pPrefs Attachment preferences taken liberty_attachment_prefs
 * @param array $pParams Parameters for loading the plugin - e.g.: might contain values such as thumbnail size from the view page
 * @access public
 * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
 */
function mime_pbase_load(&$pFileHash, &$pPrefs, $pParams = NULL)
{
    $ret = array();
    if ($ret = mime_default_load($pFileHash, $pPrefs, $pParams)) {
        $ret['display_url'] = 'http://www.pbase.com/image/' . $pFileHash['foreign_id'];
        $ret['thumbnail_url']['small'] = 'http://www.pbase.com/image/' . $pFileHash['foreign_id'] . '/small.jpg';
        $ret['thumbnail_url']['medium'] = 'http://www.pbase.com/image/' . $pFileHash['foreign_id'] . '/medium.jpg';
        $ret['thumbnail_url']['large'] = 'http://www.pbase.com/image/' . $pFileHash['foreign_id'] . '/large.jpg';
        $ret['is_mime'] = TRUE;
    }
    return $ret;
}
Пример #2
0
/**
 * Load file data from the database
 *
 * @param array $pFileHash Contains all file information
 * @param array $pPrefs Attachment preferences taken liberty_attachment_prefs
 * @param array $pParams Parameters for loading the plugin - e.g.: might contain values such as thumbnail size from the view page
 * @access public
 * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
 */
function mime_pdf_load(&$pFileHash, &$pPrefs, $pParams = NULL)
{
    global $gBitSystem;
    // don't load a mime image if we don't have an image for this file
    if ($ret = mime_default_load($pFileHash, $pPrefs, $pParams)) {
        if (!empty($ret['source_file'])) {
            $source_path = dirname($ret['source_file']) . '/';
            // if the swf file exists, we pass it back that it can be viewed.
            if (is_file($source_path . 'pdf.swf')) {
                $ret['media_url'] = storage_path_to_url(dirname($ret['source_url']) . '/pdf.swf');
            }
        }
    }
    return $ret;
}
Пример #3
0
/**
 * Load file data from the database
 *
 * @param array $pFileHash Contains all file information
 * @param array $pPrefs Attachment preferences taken liberty_attachment_prefs
 * @param array $pParams Parameters for loading the plugin - e.g.: might contain values such as thumbnail size from the view page
 * @access public
 * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason
 */
function mime_image_load(&$pFileHash, &$pPrefs, $pParams = NULL)
{
    global $gBitSystem;
    // don't load a mime image if we don't have an image for this file
    if ($ret = mime_default_load($pFileHash, $pPrefs, $pParams)) {
        // fetch meta data from the db
        $ret['meta'] = LibertyMime::getMetaData($ret['attachment_id'], "EXIF");
        // if we have GPS data and geo is active, we calculate geo stuff
        if ($gBitSystem->isPackageActive('geo') && ($ret['gps'] = LibertyMime::getMetaData($ret['attachment_id'], "GPS"))) {
            // longitude
            if (!empty($ret['gps']['gpslongitude'])) {
                $ret['geo']['lng'] = $ret['gps']['gpslongitude'];
                if (!empty($ret['gps']['gpslongituderef']) && $ret['gps']['gpslongituderef'] == 'W') {
                    $ret['geo']['lng'] = 0 - $ret['geo']['lng'];
                }
            }
            // latitude
            if (!empty($ret['gps']['gpslatitude'])) {
                $ret['geo']['lat'] = $ret['gps']['gpslatitude'];
                if (!empty($ret['gps']['gpslatituderef']) && $ret['gps']['gpslatituderef'] == 'S') {
                    $ret['geo']['lat'] = 0 - $ret['geo']['lat'];
                }
            }
            // set sea level data when available
            if (!empty($ret['gps']['gpsaltitude'])) {
                list($dividend, $divisor) = explode("/", $ret['gps']['gpsaltitude']);
                $ret['geo']['amsl'] = $dividend / $divisor;
                $ret['geo']['amsl_unit'] = 'm';
            }
            // final check to see if we have enough data
            if (empty($ret['geo']['lng']) || empty($ret['geo']['lat'])) {
                unset($ret['geo']);
            }
        }
        // check for panorama image
        if (isset($ret['source_file']) && is_file(dirname($ret['source_file']) . "/thumbs/panorama.jpg")) {
            // if the panorama doesn't have 180⁰ vertical field of view we will restrict up / down movement
            if (($ret['pano'] = LibertyMime::getMetaData($ret['attachment_id'], "PANO")) && !empty($ret['pano']['aspect'])) {
                // calculation based on logarythmic regression curve
                $ret['pano']['pa'] = round(40 - 31 * log($ret['pano']['aspect'] - 1.4));
                if ($ret['pano']['pa'] > 49) {
                    $ret['pano']['pa'] = 90;
                } elseif ($ret['pano']['pa'] < 0) {
                    $ret['pano']['pa'] = 0;
                }
            }
            $ret['thumbnail_url']['panorama'] = storage_path_to_url(dirname($ret['source_file']) . "/thumbs/panorama.jpg");
        }
    }
    return $ret;
}
Пример #4
0
/**
 * Load file data from the database
 *
 * @param array $pFileHash Contains all file information
 * @param array $pPrefs Attachment preferences taken liberty_attachment_prefs
 * @param array $pParams Parameters for loading the plugin - e.g.: might contain values from the view page
 * @access public
 * @return TRUE on success, FALSE on failure - ['errors'] will contain reason for failure
 */
function mime_video_load($pFileHash, &$pPrefs, $pParams = NULL)
{
    global $gLibertySystem, $gBitThemes;
    if ($ret = mime_default_load($pFileHash, $pParams)) {
        // check for status of conversion
        if (!empty($ret['source_file'])) {
            $source_path = STORAGE_PKG_PATH . dirname($ret['source_file']) . '/';
            if (is_file($source_path . 'error')) {
                $ret['status']['error'] = TRUE;
            } elseif (is_file($source_path . 'processing')) {
                $ret['status']['processing'] = TRUE;
            } elseif (is_file($source_path . 'flick.flv')) {
                $ret['media_url'] = storage_path_to_url(dirname($ret['source_file']) . '/flick.flv');
            } elseif (is_file($source_path . 'flick.mp4')) {
                $ret['media_url'] = storage_path_to_url(dirname($ret['source_file']) . '/flick.mp4');
            }
        }
        // now that we have the original width and height, we can get the displayed values
        $ret['meta'] = array_merge(LibertyMime::getMetaData($pFileHash['attachment_id'], "Video"), $pPrefs);
        mime_video_calculate_videosize($ret['meta'], $pParams);
    }
    return $ret;
}
Пример #5
0
/**
 * Load file data from the database
 * 
 * @param array $pFileHash Contains all file information
 * @param array $pPrefs Attachment preferences taken liberty_attachment_prefs
 * @param array $pParams Parameters for loading the plugin - e.g.: might contain values from the view page
 * @access public
 * @return TRUE on success, FALSE on failure - ['errors'] will contain reason for failure
 */
function mime_audio_load(&$pFileHash, &$pPrefs, $pParams = NULL)
{
    global $gLibertySystem, $gBitThemes;
    // don't load a mime image if we don't have an image for this file
    if ($ret = mime_default_load($pFileHash, $pPrefs, $pParams)) {
        // fetch meta data from the db
        $ret['meta'] = LibertyMime::getMetaData($pFileHash['attachment_id'], "ID3");
        if (!empty($ret['storage_path'])) {
            if (is_file(dirname(STORAGE_PKG_PATH . $ret['storage_path']) . '/bitverted.mp3')) {
                $ret['media_url'] = storage_path_to_url(dirname($ret['storage_path'])) . '/bitverted.mp3';
                // we need some javascript for the player:
            } elseif (is_file(dirname(STORAGE_PKG_PATH . $ret['storage_path']) . '/bitverted.m4a')) {
                $ret['media_url'] = storage_path_to_url(dirname($ret['storage_path'])) . '/bitverted.m4a';
            }
        }
    }
    return $ret;
}