Ejemplo n.º 1
0
function osm_render_media($content, $picture)
{
    global $template, $picture, $conf;
    //print_r( $picture['current']);
    // do nothing if the current picture is actually an image !
    if (array_key_exists('src_image', @$picture['current']) && @$picture['current']['src_image']->is_original()) {
        return $content;
    }
    // If not a GPX file
    if (array_key_exists('path', @$picture['current']) && strpos($picture['current']['path'], ".gpx") === false) {
        return $content;
    }
    $filename = embellish_url(get_gallery_home_url() . $picture['current']['element_url']);
    $height = isset($conf['osm_conf']['gpx']['height']) ? $conf['osm_conf']['gpx']['height'] : '500';
    $width = isset($conf['osm_conf']['gpx']['width']) ? $conf['osm_conf']['gpx']['width'] : '320';
    $local_conf = array();
    $local_conf['contextmenu'] = 'false';
    $local_conf['control'] = true;
    $local_conf['img_popup'] = false;
    $local_conf['popup'] = 2;
    $local_conf['center_lat'] = 0;
    $local_conf['center_lng'] = 0;
    $local_conf['zoom'] = '12';
    $local_conf['divname'] = 'mapgpx';
    $js_data = array(array(null, null, null, null, null, null, null, null));
    $js = osm_get_js($conf, $local_conf, $js_data);
    // Select the template
    $template->set_filenames(array('osm_content' => dirname(__FILE__) . "/template/osm-gpx.tpl"));
    // Assign the template variables
    $template->assign(array('HEIGHT' => $height, 'WIDTH' => $width, 'FILENAME' => $filename, 'OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'OSMGPX' => $js));
    // Return the rendered html
    $osm_content = $template->parse('osm_content', true);
    return $osm_content;
}
Ejemplo n.º 2
0
function osm_apply_menu($menu_ref_arr)
{
    global $template, $page, $conf;
    $menu =& $menu_ref_arr[0];
    if (($block = $menu->get_block('mbLinks')) != null) {
        include_once dirname(__FILE__) . '/include/functions.php';
        include_once dirname(__FILE__) . '/include/functions_map.php';
        osm_load_language();
        load_language('plugin.lang', OSM_PATH);
        // Comment are used only with this condition index.php l294
        if ($page['start'] == 0 and !isset($page['chronology_field'])) {
            $js_data = osm_get_items($page);
            if ($js_data != array()) {
                $local_conf = array();
                $local_conf['contextmenu'] = 'false';
                $local_conf['control'] = true;
                $local_conf['img_popup'] = false;
                $local_conf['popup'] = 2;
                $local_conf['center_lat'] = 0;
                $local_conf['center_lng'] = 0;
                $local_conf['zoom'] = 2;
                $local_conf['autocenter'] = 1;
                $local_conf['divname'] = 'mapmenu';
                $local_conf['paths'] = osm_get_gps($page);
                $height = isset($conf['osm_conf']['main_menu']['height']) ? $conf['osm_conf']['main_menu']['height'] : '200';
                $js = osm_get_js($conf, $local_conf, $js_data);
                $template->set_template_dir(dirname(__FILE__) . '/template/');
                $template->assign(array('OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'OSMJS' => $js, 'HEIGHT' => $height));
                $block->template = 'osm-menu.tpl';
            }
        }
    }
}
function osm_render_category()
{
    global $template, $page, $conf, $filter;
    include_once dirname(__FILE__) . '/include/functions.php';
    include_once dirname(__FILE__) . '/include/functions_map.php';
    osm_load_language();
    load_language('plugin.lang', OSM_PATH);
    // TF, 20160102: pass config as parameter
    $js_data = osm_get_items($conf, $page);
    if ($js_data != array()) {
        $local_conf = array();
        $local_conf['contextmenu'] = 'false';
        $local_conf['control'] = true;
        $local_conf['img_popup'] = false;
        $local_conf['popup'] = 1;
        $local_conf['center_lat'] = 0;
        $local_conf['center_lng'] = 0;
        $local_conf['zoom'] = 2;
        $local_conf['auto_center'] = 1;
        // TF, 20160102: pass config as parameter
        $local_conf['paths'] = osm_get_gps($conf, $page);
        $height = isset($conf['osm_conf']['category_description']['height']) ? $conf['osm_conf']['category_description']['height'] : '200';
        $width = isset($conf['osm_conf']['category_description']['width']) ? $conf['osm_conf']['category_description']['width'] : 'auto';
        $js = osm_get_js($conf, $local_conf, $js_data);
        $template->set_filename('map', dirname(__FILE__) . '/template/osm-category.tpl');
        $template->assign(array('CONTENT_ENCODING' => get_pwg_charset(), 'OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'HOME' => make_index_url(), 'HOME_PREV' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : get_absolute_root_url(), 'HOME_NAME' => l10n("Home"), 'HOME_PREV_NAME' => l10n("Previous"), 'OSMJS' => $js, 'HEIGHT' => $height, 'WIDTH' => $width));
        $osm_content = $template->parse('map', true);
        //$osm_content = '<div id="osmmap"><div class="map_title">'.l10n('EDIT_MAP').'</div>' . $osm_content . '</div>';
        $index = isset($conf['osm_conf']['category_description']['index']) ? $conf['osm_conf']['category_description']['index'] : 0;
        // 0 - PLUGIN_INDEX_CONTENT_BEGIN
        // 1 - PLUGIN_INDEX_CONTENT_COMMENT
        // 2 - PLUGIN_INDEX_CONTENT_END
        if ($index <= 1) {
            // From index category comment at L300
            if ($page['start'] == 0 and !isset($page['chronology_field'])) {
                if (empty($page['comment'])) {
                    $page['comment'] = $osm_content;
                } else {
                    if ($index == 0) {
                        $page['comment'] = '<div>' . $osm_content . $page['comment'] . '</div>';
                    } else {
                        $page['comment'] = '<div>' . $page['comment'] . $osm_content . '</div>';
                    }
                }
            }
        } else {
            $osm_content = '<div id="osmmap">' . $osm_content . '</div>';
            $template->concat('PLUGIN_INDEX_CONTENT_END', "\n" . $osm_content);
        }
    }
}
Ejemplo n.º 4
0
function forecast_render_element_content()
{
    global $template, $picture, $page, $conf;
    load_language('plugin.lang', FORECAST_PATH);
    if (empty($page['image_id']) and !is_numeric($page['image_id'])) {
        return;
    }
    // Load coordinates and date_creation from picture
    $query = "SELECT latitude,longitude,date FROM forecast WHERE id='" . $page['image_id'] . "';";
    //FIXME LIMIT 1 ?
    $result = pwg_query($query);
    $row = pwg_db_fetch_assoc($result);
    if (!isset($row) or !isset($row['latitude']) or empty($row['latitude']) or !isset($row['longitude']) or empty($row['longitude']) or !isset($row['date']) or empty($row['date'])) {
        return;
    }
    $lat = $row['latitude'];
    $lon = $row['longitude'];
    $date = $row['date'];
    // Load parameter, fallback to default if unset
    $fc_height = isset($conf['forecast_conf']['height']) ? $conf['forecast_conf']['height'] : '200';
    $fc_header = isset($conf['forecast_conf']['link']) ? $conf['forecast_conf']['link'] : 'Overcast';
    $fc_header_css = isset($conf['forecast_conf']['linkcss']) ? $conf['forecast_conf']['linkcss'] : '';
    $fc_show_link = isset($conf['forecast_conf']['show']) ? $conf['forecast_conf']['show'] : 'true';
    $fc_api_key = isset($conf['forecast_conf']['api_key']) ? $conf['forecast_conf']['api_key'] : '';
    if (strlen($fc_header_css) != 0) {
        $fc_css = "style='" . $fc_header_css . "'";
    }
    $fc_link = "http://forecast.io/#/f/" . $lat . "," . $lon;
    //  Init Forecast.io lib
    include 'lib/forecast.io.php';
    // Can be set to 'us', 'si', 'ca', 'uk' or 'auto' (see forecast.io API); default is auto
    // Can be set to 'en', 'de', 'pl', 'es', 'fr', 'it', 'tet' or 'x-pig-latin' (see forecast.io API); default is 'en'
    $fc_unit = isset($conf['forecast_conf']['unit']) ? $conf['forecast_conf']['unit'] : 'auto';
    $fc_lang = isset($conf['forecast_conf']['lang']) ? $conf['forecast_conf']['lang'] : 'en';
    /* Do we have a Forecast.io API key */
    if (strlen($fc_api_key) != 0) {
        // Make a request to Forecast.io using the user supply API, proxy set to false
        $forecast = new ForecastIO($fc_api_key, $fc_unit, $fc_lang, false);
    } else {
        /**
         * Make a request to https://forecast-xbgmsharp.rhcloud.com
         * to non disclose the Forecast.io API key, proxy set to true
         * Source code at https://github.com/xbgmsharp/nodejs-forecast
         **/
        $forecast = new ForecastIO($fc_api_key, $fc_unit, $fc_lang, true);
    }
    $condition = $forecast->getHistoricalConditions($lat, $lon, $date);
    if (!isset($condition) or $condition === 'false') {
        return;
    }
    //print_r($condition);
    // Parse weather condition to human readable
    $condition = parseCondition($condition);
    // Select the template
    $template->set_filenames(array('forecast_content' => dirname(__FILE__) . "/template/picture.tpl"));
    // Assign the template variables
    $template->assign(array('FORECAST_HEIGHT' => $fc_height, 'FORECAST_PATH' => embellish_url(get_gallery_home_url() . FORECAST_PATH), 'FORECAST_NAME' => $fc_header, 'FORECAST_NAME_CSS' => $fc_header_css, 'FORECAST_SHOW_LINK' => $fc_show_link, 'FORECAST_LINK' => $fc_link, 'FORECAST_DATA' => $condition));
    // Return the rendered html
    $forecast_content = $template->parse('forecast_content', true);
    return $forecast_content;
}
Ejemplo n.º 5
0
Archivo: i.php Proyecto: donseba/Piwigo
function send_derivative($expires)
{
    global $page;
    if (isset($_GET['ajaxload']) and $_GET['ajaxload'] == 'true') {
        include_once PHPWG_ROOT_PATH . 'include/functions_cookie.inc.php';
        include_once PHPWG_ROOT_PATH . 'include/functions_url.inc.php';
        echo json_encode(array('url' => embellish_url(get_absolute_root_url() . $page['derivative_path'])));
        return;
    }
    $fp = fopen($page['derivative_path'], 'rb');
    $fstat = fstat($fp);
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $fstat['mtime']) . ' GMT');
    if ($expires !== false) {
        header('Expires: ' . gmdate('D, d M Y H:i:s', $expires) . ' GMT');
    }
    header('Content-length: ' . $fstat['size']);
    header('Connection: close');
    $ctype = "application/octet-stream";
    switch (strtolower($page['derivative_ext'])) {
        case ".jpe":
        case ".jpeg":
        case ".jpg":
            $ctype = "image/jpeg";
            break;
        case ".png":
            $ctype = "image/png";
            break;
        case ".gif":
            $ctype = "image/gif";
            break;
    }
    header("Content-Type: {$ctype}");
    fpassthru($fp);
    fclose($fp);
}
Ejemplo n.º 6
0
 /**
  * @return string
  */
 function get_url()
 {
     if ($this->params == null) {
         return $this->src_image->get_url();
     }
     return embellish_url(trigger_change('get_derivative_url', get_root_url() . $this->rel_url, $this->params, $this->src_image, $this->rel_url));
 }
Ejemplo n.º 7
0
function vjs_render_media($content, $picture)
{
    global $template, $picture, $page, $conf, $user, $refresh;
    //print_r( $picture['current']);
    // do nothing if the current picture is actually an image !
    if (array_key_exists('src_image', @$picture['current']) && @$picture['current']['src_image']->is_original()) {
        return $content;
    }
    // In case it is not an image but not a supported video file by the plugin
    if (vjs_valid_extension(get_extension($picture['current']['path'])) === false) {
        return $content;
    }
    // In case, we handle a large video, we define a MAX_HEIGHT
    // variable to limit the display size.
    $MAX_HEIGHT = isset($conf['vjs_conf']['max_height']) ? $conf['vjs_conf']['max_height'] : '480';
    if (isset($user['maxheight']) and $user['maxheight'] != '') {
        $MAX_HEIGHT = $user['maxwidth'];
    }
    //print "MAX_HEIGHT=" . $MAX_HEIGHT;
    //print_r($user);
    $extension = vjs_get_mimetype_from_ext(get_extension($picture['current']['path']));
    //print "extension\n";
    //print_r($extension);
    // Video file -- Guess resolution base on height
    if (isset($picture['current']['width'])) {
        $width = $picture['current']['width'];
    }
    if (isset($picture['current']['height'])) {
        $height = $picture['current']['height'];
    }
    if (!isset($width) || !isset($height) || $width == 0 || $height == 0) {
        // If guess was unsuccessful, fallback to default 16/9 resolution 720x480
        // Mostly happend when video metadata was incorrectly sync into PWG
        // This is the case for ogv video for example.
        $height = 480;
        $width = round(16 * 480 / 9, 0);
    }
    //print "Video height=" . $height . " width=". $width;
    // Resize if video is too height
    //print $height .">". $MAX_HEIGHT;
    if ($height > $MAX_HEIGHT) {
        $height = $MAX_HEIGHT;
        $width = round(16 * $MAX_HEIGHT / 9, 0);
        //print "MAX_HEIGHT height=" . $height . " width=". $width;
    }
    // Upscale if video is too small
    $upscale = isset($conf['vjs_conf']['upscale']) ? strbool($conf['vjs_conf']['upscale']) : false;
    if ($upscale and $height < $MAX_HEIGHT) {
        $height = $MAX_HEIGHT;
        $width = round(16 * $MAX_HEIGHT / 9, 0);
        //print "UPSCALE height=" . $height . " width=". $width;
    }
    // Load parameter, fallback to default if unset
    $skin = isset($conf['vjs_conf']['skin']) ? $conf['vjs_conf']['skin'] : 'vjs-default-skin';
    $customcss = isset($conf['vjs_customcss']) ? $conf['vjs_customcss'] : '';
    $preload = isset($conf['vjs_conf']['preload']) ? $conf['vjs_conf']['preload'] : 'none';
    $loop = isset($conf['vjs_conf']['loop']) ? strbool($conf['vjs_conf']['loop']) : false;
    $controls = isset($conf['vjs_conf']['controls']) ? strbool($conf['vjs_conf']['controls']) : false;
    $volume = isset($conf['vjs_conf']['volume']) ? $conf['vjs_conf']['volume'] : '1';
    $language = isset($conf['vjs_conf']['language']) ? $conf['vjs_conf']['language'] : 'en';
    // Slideshow : The video needs to be launch automatically in
    // slideshow mode. The refresh of the page is set to the
    // duration of the video.
    $autoplay = isset($conf['vjs_conf']['autoplay']) ? strbool($conf['vjs_conf']['autoplay']) : false;
    if ($page['slideshow']) {
        $refresh = 20;
        // TODO move to separate DB to actualy get this details information
        $autoplay = true;
        $loop = false;
    }
    // Assing the CSS file according to the skin
    $available_skins = array('vjs-default-skin' => 'video-js.min.css', 'vjs-bluebox-skin' => 'bluebox-skin.css', 'vjs-redtube-skin' => 'redtube-skin.css');
    $skincss = $available_skins[$skin];
    // Guess the poster extension
    $file_wo_ext = pathinfo($picture['current']['path']);
    $file_dir = dirname($picture['current']['path']);
    $poster = embellish_url($picture['current']['src_image']->get_path());
    //print $poster;
    // Try to find multiple video source
    $vjs_extensions = array('ogg', 'ogv', 'mp4', 'm4v', 'webm', 'webmv');
    $files_ext = array_merge(array(), $vjs_extensions, array_map('strtoupper', $vjs_extensions));
    // Add the current file in array
    $videos[] = array('src' => embellish_url($picture['current']['element_url']), 'ext' => $extension);
    // Add any other video source format
    foreach ($files_ext as $file_ext) {
        $file = $file_dir . "/pwg_representative/" . $file_wo_ext['filename'] . "." . $file_ext;
        if (file_exists($file)) {
            array_push($videos, array('src' => embellish_url(get_gallery_home_url() . $file_dir . "/pwg_representative/" . $file_wo_ext['filename'] . "." . $file_ext), 'ext' => vjs_get_mimetype_from_ext($file_ext)));
        }
    }
    //print_r($videos);
    // Sort array to have MP4 first in the source list for iOS support
    foreach ($videos as $key => $row) {
        $src[$key] = $row['src'];
        $ext[$key] = $row['ext'];
    }
    array_multisort($src, SORT_ASC, $ext, SORT_ASC, $videos);
    //print_r($videos);
    /* Try to find WebVTT */
    $file = $file_dir . "/pwg_representative/" . $file_wo_ext['filename'] . ".vtt";
    $subtitles = null;
    if (file_exists($file)) {
        $subtitles = '<track kind="subtitles" src="' . embellish_url(get_gallery_home_url() . $file) . '" srclang="' . $language . '" label="English"></track>';
    }
    /* Thumbnail videojs plugin */
    $thumbnails_plugin = isset($conf['vjs_conf']['plugins']['thumbnails']) ? strbool($conf['vjs_conf']['plugins']['thumbnails']) : false;
    $thumbnails = array();
    if ($thumbnails_plugin) {
        $filematch = $file_dir . "/pwg_representative/" . $file_wo_ext['filename'] . "-th_*";
        $matches = glob($filematch);
        if (is_array($matches) and !empty($matches)) {
            $sort = array();
            // A list of sort columns and their data to pass to array_multisort
            foreach ($matches as $filename) {
                $ext = explode("-th_", $filename);
                $second = explode(".", $ext[1]);
                include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
                include_once PHPWG_ROOT_PATH . 'admin/include/image.class.php';
                $rotate = pwg_image::get_rotation_angle_from_code($picture['current']['rotation']);
                // ./galleries/videos/pwg_representative/trailer_480p-th_0.jpg
                //echo "$filename second " . $second[0]. "\n";
                $thumbnails[] = array('second' => $second[0], 'source' => embellish_url(get_gallery_home_url() . $filename), 'rotate' => $rotate);
                $sort['second'][$second[0]] = $second[0];
            }
            // Sort thumbnails by second ASC
            !empty($sort['second']) and array_multisort($sort['second'], SORT_ASC, $thumbnails);
        }
        //$thumbnails = array( array('second' => 0, 'source' => $poster), array('second' => 5, 'source' => $poster));
        //print_r($thumbnails);
    }
    /* ZoomRotate videojs plugin */
    $zoomrotate_plugin = isset($conf['vjs_conf']['plugins']['zoomrotate']) ? strbool($conf['vjs_conf']['plugins']['zoomrotate']) : false;
    $zoomrotate = array();
    if ($zoomrotate_plugin) {
        // TODO Disable if playing on iOS, as it read the metadata itself
        if ($picture['current']['rotation'] != null) {
            include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
            include_once PHPWG_ROOT_PATH . 'admin/include/image.class.php';
            // rotation is $picture['current']['rotation']
            // zoom is witdh / height
            $rotate = pwg_image::get_rotation_angle_from_code($picture['current']['rotation']);
            $zoomrotate = array('rotate' => $rotate, 'zoom' => round($width / $height, 1, PHP_ROUND_HALF_DOWN));
            // Change the video player size
            $tmp_width = $width;
            $tmp_height = $height;
            $width = $tmp_height;
            $height = $tmp_width;
        }
    }
    /* Watermark videojs plugin */
    $watermark_plugin = isset($conf['vjs_conf']['plugins']['watermark']) ? strbool($conf['vjs_conf']['plugins']['watermark']) : false;
    $watermark = array();
    if ($watermark_plugin) {
        $derivatives = unserialize($conf['derivatives']);
        if (is_array($derivatives) and !empty($derivatives) and $derivatives['w']->file != null) {
            $watermark = array('file' => embellish_url(get_gallery_home_url() . $derivatives['w']->file), 'xpos' => $derivatives['w']->xpos, 'ypos' => $derivatives['w']->ypos, 'xrepeat' => $derivatives['w']->xrepeat, 'opacity' => $derivatives['w']->opacity);
        }
    }
    // Generate HTML5 tags
    // Why the data-setup attribute does not work if only one video
    $options = "";
    if ($controls) {
        $options .= "controls";
    }
    if ($autoplay) {
        $options .= " autoplay ";
    }
    if ($loop) {
        $options .= " loop ";
    }
    $options .= ' preload="' . $preload . '"';
    // Select the template
    $template->set_filenames(array('vjs_content' => dirname(__FILE__) . "/template/vjs-player.tpl"));
    // Ensure the ratio is always below 100%, there is for sure a better way!
    $ratio = round($height / $width * 100, 2);
    if ($ratio >= 100) {
        $ratio = round($width / $height * 100, 2);
    }
    // Assign the template variables
    // We use here the piwigo's get_gallery_home_url function to build
    // the full URL as suggested by videojs for flash fallback compatibility
    $template->assign(array('VIDEOJS_POSTER_URL' => embellish_url(get_gallery_home_url() . $poster), 'VIDEOJS_PATH' => embellish_url(get_gallery_home_url() . VIDEOJS_PATH), 'WIDTH' => $width, 'RATIO' => $ratio, 'OPTIONS' => $options, 'VIDEOJS_SKIN' => $skin, 'VIDEOJS_SKINCSS' => $skincss, 'VIDEOJS_CUSTOMCSS' => $customcss, 'volume' => $volume, 'subtitles' => $subtitles, 'thumbnails' => $thumbnails, 'zoomrotate' => $zoomrotate, 'watermark' => $watermark, 'videos' => $videos));
    // Return the rendered html
    $vjs_content = $template->parse('vjs_content', true);
    return $vjs_content;
}
Ejemplo n.º 8
0
 /**
  * Resolves relative links in CSS file.
  *
  * @param string $css file content
  * @param string $dir
  * @param string $header CSS directives that must appear first in
  *                       the minified file.
  * @return string
  */
 private static function process_css_rec($css, $dir, &$header)
 {
     static $PATTERN_URL = "#url\\(\\s*['|\"]{0,1}(.*?)['|\"]{0,1}\\s*\\)#";
     static $PATTERN_IMPORT = "#@import\\s*['|\"]{0,1}(.*?)['|\"]{0,1};#";
     if (preg_match_all($PATTERN_URL, $css, $matches, PREG_SET_ORDER)) {
         $search = $replace = array();
         foreach ($matches as $match) {
             if (!url_is_remote($match[1]) && $match[1][0] != '/' && strpos($match[1], 'data:image/') === false) {
                 $relative = $dir . "/{$match['1']}";
                 $search[] = $match[0];
                 $replace[] = 'url(' . embellish_url(get_absolute_root_url(false) . $relative) . ')';
             }
         }
         $css = str_replace($search, $replace, $css);
     }
     if (preg_match_all($PATTERN_IMPORT, $css, $matches, PREG_SET_ORDER)) {
         $search = $replace = array();
         foreach ($matches as $match) {
             $search[] = $match[0];
             if (strpos($match[1], '..') !== false or strpos($match[1], '://') !== false or !is_readable(PHPWG_ROOT_PATH . $dir . '/' . $match[1])) {
                 // If anything is suspicious, don't try to process the
                 // @import. Since @import need to be first and we are
                 // concatenating several CSS files, remove it from here and return
                 // it through $header.
                 $header .= $match[0];
                 $replace[] = '';
             } else {
                 $sub_css = file_get_contents(PHPWG_ROOT_PATH . $dir . "/{$match['1']}");
                 $replace[] = self::process_css_rec($sub_css, dirname($dir . "/{$match['1']}"), $header);
             }
         }
         $css = str_replace($search, $replace, $css);
     }
     return $css;
 }
function get_element_url($element_info)
{
    $url = $element_info['path'];
    if (!url_is_remote($url)) {
        $url = embellish_url(get_root_url() . $url);
    }
    return $url;
}
Ejemplo n.º 10
0
    if (file_exists($file)) {
        array_push($videos, array('src' => embellish_url(get_gallery_home_url() . $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . "." . $file_ext), 'ext' => vjs_get_mimetype_from_ext($file_ext)));
    }
}
//print_r($videos);
/* Try to find WebVTT */
$file = $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . ".vtt";
file_exists($file) ? $subtitle = embellish_url(get_gallery_home_url() . $file) : ($subtitle = null);
/* Thumbnail videojs plugin */
$filematch = $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . "-th_*";
$matches = glob($filematch);
$thumbnails = array();
$sort = array();
// A list of sort columns and their data to pass to array_multisort
if (is_array($matches) and !empty($matches)) {
    foreach ($matches as $filename) {
        $ext = explode("-th_", $filename);
        $second = explode(".", $ext[1]);
        // ./galleries/videos/pwg_representative/trailer_480p-th_0.jpg
        //echo "$filename second " . $second[0]. "\n";
        $thumbnails[] = array('second' => $second[0], 'source' => embellish_url(get_gallery_home_url() . $filename));
        $sort['second'][$second[0]] = $second[0];
    }
}
//print_r($thumbnails);
// Sort thumbnails by second
!empty($sort['second']) and array_multisort($sort['second'], SORT_ASC, $thumbnails);
$infos = array_merge(array('Poster' => $poster), array('Videos source' => count($videos)), array('videos' => $videos), array('Thumbnails' => count($thumbnails)), array('thumbnails' => $thumbnails), array('Subtitle' => $subtitle));
//print_r($infos);
$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'F_ACTION' => $self_url, 'SYNC_URL' => $sync_url, 'DELETE_URL' => $delete_url, 'TN_SRC' => DerivativeImage::thumb_url($picture) . '?' . time(), 'TITLE' => render_element_name($picture), 'EXIF' => $exif, 'INFOS' => $infos));
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Ejemplo n.º 11
0
}
$local_conf = array();
$local_conf['contextmenu'] = 'false';
$local_conf['control'] = true;
$local_conf['img_popup'] = false;
$local_conf['popup'] = 2;
$local_conf['center_lat'] = $lat;
$local_conf['center_lng'] = $lon;
$local_conf['zoom'] = $zoom;
$local_conf['editor'] = true;
$pathurl = get_absolute_root_url() . "i.php?" . $picture['pathurl'];
$js_data = array(array($lat, $lon, null, $pathurl, null, null, null, null));
$js = osm_get_js($conf, $local_conf, $js_data);
// Fetch the template.
global $prefixeTable;
// Easy access
define('osm_place_table', $prefixeTable . 'osm_places');
// Save location, eg Place
$query = '
SELECT id, name, latitude, longitude
  FROM ' . osm_place_table . '
;';
$result = pwg_query($query);
// JS for the template
while ($row = pwg_db_fetch_assoc($result)) {
    $list_of_places[$row['id']] = [$row['name'], $row['latitude'], $row['longitude']];
    $available_places[$row['id']] = $row['name'];
}
$jsplaces = "\nvar arr_places = " . json_encode($list_of_places) . ";\n";
$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'F_ACTION' => $self_url, 'TN_SRC' => DerivativeImage::thumb_url($picture) . '?' . time(), 'TITLE' => render_element_name($picture), 'OSM_PATH' => embellish_url(get_absolute_root_url() . OSM_PATH), 'OSM_JS' => $js, 'LAT' => $lat, 'LON' => $lon, 'AVAILABLE_PLACES' => $available_places, 'LIST_PLACES' => $jsplaces));
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Ejemplo n.º 12
0
function osm_gen_template($conf, $js, $js_data, $tmpl, $template)
{
    $linkname = isset($conf['osm_conf']['left_menu']['link']) ? $conf['osm_conf']['left_menu']['link'] : l10n('OSWorldMap');
    $template->set_filename('map', dirname(__FILE__) . '/../template/' . $tmpl);
    $template->assign(array('CONTENT_ENCODING' => get_pwg_charset(), 'OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'GALLERY_TITLE' => $linkname . ' - ' . $conf['gallery_title'], 'HOME' => make_index_url(), 'HOME_PREV' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : get_absolute_root_url(), 'HOME_NAME' => l10n("Home"), 'HOME_PREV_NAME' => l10n("Previous"), 'TOTAL' => sprintf(l10n('ITEMS'), count($js_data)), 'OSMJS' => $js, 'MYROOT_URL' => get_absolute_root_url(), 'default_baselayer' => $conf['osm_conf']['map']['baselayer']));
    if ($conf['osm_conf']['map']['baselayer'] == 'custom') {
        $iconbaselayer = $conf['osm_conf']['map']['custombaselayerurl'];
        $iconbaselayer = str_replace('{s}', 'a', $iconbaselayer);
        $iconbaselayer = str_replace('{z}', '5', $iconbaselayer);
        $iconbaselayer = str_replace('{x}', '15', $iconbaselayer);
        $iconbaselayer = str_replace('{y}', '11', $iconbaselayer);
        $template->assign(array('custombaselayer' => $conf['osm_conf']['map']['custombaselayer'], 'custombaselayerurl' => $conf['osm_conf']['map']['custombaselayerurl'], 'iconbaselayer' => $iconbaselayer));
    }
    $template->pparse('map');
    $template->p();
}
function osm_render_element_content()
{
    global $template, $picture, $page, $conf;
    load_language('plugin.lang', OSM_PATH);
    if (empty($page['image_id'])) {
        return;
    }
    // Load coordinates from picture
    $query = 'SELECT latitude,longitude FROM ' . IMAGES_TABLE . ' WHERE id = \'' . $page['image_id'] . '\' ;';
    //FIXME LIMIT 1 ?
    $result = pwg_query($query);
    $row = pwg_db_fetch_assoc($result);
    if (!$row or !$row['latitude'] or empty($row['latitude'])) {
        return;
    }
    $lat = $row['latitude'];
    $lon = $row['longitude'];
    // Load parameter, fallback to default if unset
    $height = isset($conf['osm_conf']['right_panel']['height']) ? $conf['osm_conf']['right_panel']['height'] : '200';
    $zoom = isset($conf['osm_conf']['right_panel']['zoom']) ? $conf['osm_conf']['right_panel']['zoom'] : '12';
    $osmname = isset($conf['osm_conf']['right_panel']['link']) ? $conf['osm_conf']['right_panel']['link'] : 'Location';
    $osmnamecss = isset($conf['osm_conf']['right_panel']['linkcss']) ? $conf['osm_conf']['right_panel']['linkcss'] : '';
    $showosm = isset($conf['osm_conf']['right_panel']['showosm']) ? $conf['osm_conf']['right_panel']['showosm'] : 'true';
    if (strlen($osmnamecss) != 0) {
        $osmnamecss = "style='" . $osmnamecss . "'";
    }
    $osmlink = "https://openstreetmap.org/?mlat=" . $lat . "&amp;mlon=" . $lon . "&zoom=12&layers=M";
    $local_conf = array();
    $local_conf['contextmenu'] = 'false';
    $local_conf['control'] = false;
    $local_conf['img_popup'] = false;
    $local_conf['popup'] = 2;
    $local_conf['center_lat'] = $lat;
    $local_conf['center_lng'] = $lon;
    $local_conf['zoom'] = $zoom;
    // TF, 20160102: pass config as parameter
    $js_data = osm_get_items($conf, $page);
    $js = osm_get_js($conf, $local_conf, $js_data);
    // Select the template
    $template->set_filenames(array('osm_content' => dirname(__FILE__) . "/template/osm-picture.tpl"));
    // Assign the template variables
    $template->assign(array('HEIGHT' => $height, 'OSMJS' => $js, 'OSM_PATH' => embellish_url(get_gallery_home_url() . OSM_PATH), 'OSMNAME' => $osmname, 'OSMNAMECSS' => $osmnamecss, 'SHOWOSM' => $showosm, 'OSMLINK' => $osmlink));
    // Return the rendered html
    $osm_content = $template->parse('osm_content', true);
    return $osm_content;
}
Ejemplo n.º 14
0
function render_media($content, $picture)
{
    global $template, $picture, $page, $conf, $user, $refresh;
    // do nothing if the current picture is actually an image !
    if (@$picture['current']['is_picture'] || array_key_exists('src_image', @$picture['current']) && @$picture['current']['src_image']->is_original()) {
        return $content;
    }
    // In case, the we handle a large video, we define a MAX_WIDTH
    // variable to limit the display size.
    if (isset($user['maxwidth']) and $user['maxwidth'] != '') {
        $MAX_WIDTH = $user['maxwidth'];
    } else {
        $MAX_WIDTH = '720';
    }
    // Get video infos with getID3 lib
    require_once dirname(__FILE__) . '/include/getid3/getid3.php';
    $getID3 = new getID3();
    $fileinfo = $getID3->analyze($picture['current']['path']);
    $extension = strtolower(get_extension($picture['current']['path']));
    $basename = strtolower(get_filename_wo_extension($picture['current']['path']));
    $is_video = False;
    // if not a media extension, do nothing
    if (!in_array($extension, $conf['media_ext'])) {
        return $content;
    } else {
        if (isset($fileinfo['video'])) {
            // -- video file --
            $is_video = True;
            if ($extension == 'webm') {
                $extension = 'webmv';
            }
            if ($extension == 'mp4') {
                $extension = 'm4v';
            }
            // guess resolution
            if (isset($fileinfo['video']['resolution_x'])) {
                $width = $fileinfo['video']['resolution_x'];
            }
            if (isset($fileinfo['video']['resolution_y'])) {
                $height = $fileinfo['video']['resolution_y'];
            }
            if (!isset($width) || !isset($height)) {
                // If guess was unsuccessful, fallback to default 16/9 resolution
                // This is the case for ogv video for example.
                $width = $MAX_WIDTH;
                $height = intval(9 * ($width / 16));
            }
        } else {
            // -- audio only file --
            if ($extension == 'webm') {
                $extension = 'webma';
            }
            if ($extension == 'mp4') {
                $extension = 'm4a';
            }
            if ($extension == 'ogg') {
                $extension = 'oga';
            }
            $width = '0';
            $height = '0';
        }
    }
    // Resize if video is too large
    if ($width > $MAX_WIDTH) {
        $height = intval($height * ($MAX_WIDTH / $width));
        $width = $MAX_WIDTH;
    }
    // Slideshow : The video needs to be launch automatically in
    // slideshow mode. The refresh of the page is set to the
    // duration of the video.
    if (isset($conf['jplayer_autoplay']) && $conf['jplayer_autoplay']) {
        $AUTOPLAY = 'play';
    } else {
        $AUTOPLAY = '';
    }
    if ($page['slideshow']) {
        $refresh = $fileinfo['playtime_seconds'];
        $AUTOPLAY = 'play';
    }
    // Picture representative to be used as poster image in the player
    $poster_url = NULL;
    if (isset($picture['current']['src_image']) && isset($conf['jplayer_representative_as_poster']) && $conf['jplayer_representative_as_poster']) {
        $poster_url = $picture['current']['src_image']->get_url();
        $poster_url = embellish_url(get_gallery_home_url() . $poster_url);
        if (strpos($poster_url, "mimetype")) {
            // Ignore mimetype representatives because they're too small
            $poster_url = NULL;
        }
    }
    // Load parameter, fallback to blue monday if unset
    $skin = isset($conf['jplayer_skin']) ? $conf['jplayer_skin'] : 'bm';
    // Select the template
    $template->set_filenames(array('jp_content' => dirname(__FILE__) . "/template/jp-" . $skin . ".tpl"));
    $alternate_media_url = '';
    $alternate_type = '';
    if ($extension == 'webmv') {
        if (file_exists($basename . '.m4v')) {
            $alternate_media_url = str_replace('webm', 'm4v', $picture['current']['element_url']);
            $alternate_type = 'm4v';
        }
    } else {
        if ($extension == 'm4v') {
            if (file_exists($basename . '.webm')) {
                $alternate_media_url = str_replace('m4v', 'webm', $picture['current']['element_url']);
                $alternate_type = 'webmv';
            }
        }
    }
    // Assign the template variables
    // We use here the piwigo's get_gallery_home_url function to build
    // the full URL as suggested by jplayer for flash fallback compatibility
    $template->assign(array('JP_MEDIA_URL' => embellish_url(get_gallery_home_url() . $picture['current']['element_url']), 'ALT_JP_MEDIA_URL' => embellish_url(get_gallery_home_url() . $alternate_media_url), 'JP_POSTER' => $poster_url, 'JPLAYER_PATH' => JPLAYER_PATH, 'JPLAYER_FULLPATH' => realpath(dirname(__FILE__)), 'WIDTH' => $width . 'px', 'HEIGHT' => $height . 'px', 'TYPE' => $extension, 'ALT_TYPE' => $alternate_type, 'AUTOPLAY' => $AUTOPLAY, 'IS_VIDEO' => $is_video));
    // Return the rendered html
    $jp_content = $template->parse('jp_content', true);
    return $jp_content;
}