コード例 #1
0
function videogall_migrate()
{
    $current_videos = get_option('videogall_videos');
    $current_categories = get_option('videogall_categories');
    if (!empty($current_categories)) {
        foreach ($current_categories as $entry) {
            $category = array('name' => $entry);
            videogall_insert("videogall_categories", $category);
        }
        delete_option('videogall_categories');
    }
    if (!empty($current_videos)) {
        foreach ($current_videos as $entry) {
            $catid = videogall_get_category_id($entry['category']);
            if ($catid < 1) {
                $catid = 0;
            }
            $video = array('url' => $entry['url'], 'thumbnail' => $entry['thumbnail'], 'category' => $catid, 'caption' => $entry['caption'], 'description' => $entry['description']);
            videogall_insert("videogall_videos", $video);
        }
        delete_option('videogall_videos');
    }
}
コード例 #2
0
ファイル: videogall.php プロジェクト: rodsilver83/victoria
/**
 * Display VideoGall Gallery
 */
function videogall_display_videos($category_filter = "", $isWidget = false, $number_of_videos = "")
{
    global $videogall_options, $videogall_url;
    $filter_value = "";
    /* Create category filter */
    if (trim($category_filter) != "" and !$isWidget) {
        if (preg_match('/,/', $category_filter)) {
            $category_filter = rtrim($category_filter, ",");
            $categories = explode(",", $category_filter);
            $first = true;
            foreach ($categories as $entry) {
                $catid = videogall_get_category_id($entry);
                if ($first) {
                    $filter_value .= $catid;
                } else {
                    $filter_value .= "," . $catid;
                }
                $first = false;
            }
        } else {
            $catid = videogall_get_category_id($category_filter);
            $filter_value = $catid;
        }
    } elseif (trim($category_filter) != "" and $isWidget) {
        $filter_value = $category_filter;
    }
    /* Sorts Videos */
    if ($videogall_options['video_order'] == "new_to_old") {
        $order_filter = "id desc";
    } else {
        $order_filter = "id asc";
    }
    if ($videogall_options['sort_by_category']) {
        $order_filter = "category asc, " . $order_filter;
    }
    /* Fetching videos from DB */
    $videos = videogall_get_videos_by_categories($filter_value, $order_filter, 20);
    $output = '';
    $page_count = 1;
    $video_count = 1;
    $total_videos = count($videos);
    foreach ($videos as $entry) {
        $output .= '<div id="videogall-item-' . $entry['id'] . '" class="videogall-item videogall-page-item-' . $page_count . '">' . "\n";
        if ($videogall_options['autoplay']) {
            if (preg_match('/metacafe/i', $entry['url'])) {
                $autoplay = 'ap=1';
            } elseif (preg_match('/blip/i', $entry['url'])) {
                $autoplay = 'autoplay=true';
            } else {
                $autoplay = 'autoplay=1';
            }
            if (preg_match('/\\?/', $entry['url'])) {
                $entry['url'] .= '&' . $autoplay;
            } else {
                $entry['url'] .= '?' . $autoplay;
            }
        }
        $output .= "\t" . '<a class="videogall-img-link iframe" rel="videogall" href="' . $entry['url'] . '" >' . "\n";
        $output .= "\t\t" . '<div class="videogall-thumb-box"><img class="videogall-thumb" src="' . $entry['thumbnail'] . '"/></div>' . "\n";
        $output .= "\t" . '</a>' . "\n";
        if ($entry['caption'] != "") {
            $output .= "\t" . '<p>' . $entry['caption'];
        }
        if ($entry['description'] != "" and !$isWidget) {
            $output .= '<br><span>' . $entry['description'] . '</span></p>' . "\n";
        } else {
            $output .= '</div>' . "\n";
        }
        if ($videogall_options['show_categories'] != "" and $entry['category'] != "0" and !$isWidget) {
            $output .= "\t" . '<p class="videogall-category">' . __('Category: ', 'videogall') . ucwords(videogall_get_category_name_by_id($entry['category'])) . '</p>' . "\n";
        }
        /*if(trim($entry['likes']) == "") $likes = 0; else $likes = count(explode(",",$entry['likes']));
                $output .= "\t".'<div class="videogall-meta" id="videogall-meta-'.$entry['id'].'"><a class="videogall-like" href="'.admin_url('admin-ajax.php').'">'.$likes.'</a></div>'."\n";
        		*/
        $output .= '</div>' . "\n";
        if ($video_count % $videogall_options['videos_per_page'] == 0 and $video_count < $total_videos) {
            $page_count++;
        }
        $video_count++;
        if ($number_of_videos != "") {
            if ($video_count == $number_of_videos) {
                break;
            }
        }
    }
    if ($output != "") {
        $output = '<div class="videogall-title">Videos 
				<input type="hidden" id="videogall-current-page" value="videogall-page-1">
				<div class="videogall-next" id="videogall-page-2"></div>
				<div class="videogall-prev" id="videogall-page-1"></div></div>
				<div id="videogall-container">' . $output . '</div>' . "\n";
    }
    if ($output != "" and $videogall_options['enable_pagination'] and !$isWidget) {
        $output .= '<div class="videogall-page-navigation">' . "\n";
        /* for($p = 1; $p <= $page_count; $p++) {
               if($p == 1) $current_class = ' current_page'; else $current_class = '';
               $output .= "\t".'<a id="videogall-page-'.$p.'" class="videogall-page'.$current_class.'" href="javascript:void(0)">'.$p.'</a>';
           }*/
        $output .= '</div><br>' . "\n";
    }
    return $output;
}