コード例 #1
0
 function render()
 {
     $collection_id = $_GET['gid'];
     $audio_ids = Audio::load_audios_for_collection_id($collection_id, $limit = 0);
     $this->links = $audio_ids;
     $this->audios_links = $audio_ids;
     $this->inner_HTML = $this->generate_inner_html();
     $content = parent::render();
     return $content;
 }
コード例 #2
0
 function generate_inner_html()
 {
     global $login_uid;
     if (!isset($_GET['gid']) || empty($_GET['gid'])) {
         parent::set_vars();
         $frnd_list = null;
         if (!empty($_GET['view'])) {
             $frnd_list = $this->friend_list;
         }
         $sb_audios = array();
         $new_album = new Album(AUDIO_ALBUM);
         if ($this->album_id) {
             $new_album = new Album();
             $new_album->album_type = AUDIO_ALBUM;
             $new_album->load((int) $this->album_id);
             $audio_data['album_id'] = $new_album->collection_id;
             $audio_data['album_name'] = $new_album->title;
         } else {
             $new_album->collection_id = $this->default_album_id;
             $audio_data['album_id'] = $this->default_album_id;
             $audio_data['album_name'] = $this->default_album_name;
         }
         $audio_ids = $new_album->get_contents_for_collection();
         if (!empty($audio_ids)) {
             $k = 0;
             $ids = array();
             for ($i = 0; $i < count($audio_ids); $i++) {
                 if ($audio_ids[$i]['type'] != 7) {
                     // Type 7 is for SB Content
                     $ids[$i] = $audio_ids[$i]['content_id'];
                 } else {
                     $tags = Tag::load_tags_for_content($audio_ids[$i]['content_id']);
                     $tags = show_tags($tags, null);
                     //show_tags function is defined in uihelper.php
                     $sb_audios[] = array('content_id' => $audio_ids[$i]['content_id'], 'title' => $audio_ids[$i]['title'], 'type' => $audio_ids[$i]['type'], 'created' => $audio_ids[$i]['created'], 'tags' => $tags);
                 }
             }
             $new_audio = new Audio();
             $data = $new_audio->load_many($ids, $this->uid, $login_uid);
             if (count($data) > 0) {
                 foreach ($data as $d) {
                     $audio_data[$k]['content_id'] = $d['content_id'];
                     $audio_data[$k]['audio_file'] = $d['audio_file'];
                     $audio_data[$k]['audio_caption'] = $d['audio_caption'];
                     $audio_data[$k]['title'] = $d['title'];
                     $audio_data[$k]['body'] = $d['body'];
                     $audio_data[$k]['created'] = $d['created'];
                     $audio_data[$k]['tags'] = $d['tags'];
                     $audio_data[$k]['type'] = "";
                     $k++;
                 }
             }
             // Merging Media Gallery content and SB Content
             for ($counter = 0; $counter < count($sb_audios); $counter++) {
                 $audio_data[$k]['content_id'] = $sb_audios[$counter]['content_id'];
                 $audio_data[$k]['title'] = $sb_audios[$counter]['title'];
                 $audio_data[$k]['type'] = $sb_audios[$counter]['type'];
                 $audio_data[$k]['image_caption'] = $sb_audios[$counter]['title'];
                 $audio_data[$k]['created'] = $sb_audios[$counter]['created'];
                 $audio_data[$k]['tags'] = $sb_audios[$counter]['tags'];
                 $k++;
             }
         }
         if (!empty($_GET['view'])) {
             if (empty($frnd_list)) {
                 $audio_data = NULL;
             }
         }
         $inner_template = NULL;
         switch ($this->mode) {
             default:
                 $inner_template = dirname(__FILE__) . '/center_inner_public.tpl';
         }
         $obj_inner_template =& new Template($inner_template);
         $obj_inner_template->set('links', $audio_data);
         $obj_inner_template->set('uid', $this->uid);
         $obj_inner_template->set('frnd_list', $frnd_list);
         $obj_inner_template->set('my_all_album', $this->my_all_album);
         $obj_inner_template->set('show_view', $this->show_view);
         $inner_html = $obj_inner_template->fetch();
         return $inner_html;
     } else {
         parent::set_group_media_gallery();
         //------------- Handling the Groups Media gallery -----------
         $group = ContentCollection::load_collection((int) $_GET['gid'], $_SESSION['user']['id']);
         $audio_data = Audio::load_audios_for_collection_id($_GET['gid'], $limit = 0);
         $audio_data['album_id'] = $group->collection_id;
         $audio_data['album_name'] = $group->title;
         $inner_template = NULL;
         switch ($this->mode) {
             default:
                 $inner_template = dirname(__FILE__) . '/center_inner_public_groups.tpl';
         }
         $obj_inner_template =& new Template($inner_template);
         $obj_inner_template->set('links', $audio_data);
         $obj_inner_template->set('show_view', $this->show_view);
         $obj_inner_template->set('my_all_groups', $this->group_ids);
         $inner_html = $obj_inner_template->fetch();
         return $inner_html;
     }
 }
コード例 #3
0
 function render()
 {
     $pic = $aud = $vid = NULL;
     switch ($this->page) {
         case 'homepage':
             $pic = Image::load_recent_media_image(0, $this->subject);
             $aud = Audio::load_recent_media_audio(0, $this->subject);
             $vid = TekVideo::get_media_recent_tekvideo(0, $this->subject);
             break;
         case 'grouppage':
             $pic = Image::load_images_for_collection_id((int) $this->gid);
             $aud = Audio::load_audios_for_collection_id((int) $this->gid);
             $tekvid = TekVideo::get(NULL, array('C.collection_id' => $this->group_details->collection_id));
             $vid = objtoarray($tekvid);
             break;
         case 'userpage':
             $pic = Image::load_user_gallery_images($this->uid, 10, PA::$login_uid);
             $aud = Audio::load_user_gallery_audio($this->uid, 10, PA::$login_uid);
             if (!empty(PA::$page_uid) || PA::$login_uid != PA::$page_uid) {
                 $condition['M.video_perm'] = !empty($this->friend_list) && in_array(PA::$page_uid, $this->friend_list) ? array(WITH_IN_DEGREE_1, ANYONE) : ANYONE;
             }
             $tekvid = TekVideo::get(array('show' => 10, 'page' => 1), array('C.author_id' => $this->uid));
             $vid = objtoarray($tekvid);
             $this->view_all_url = PA::$url . PA_ROUTE_MEDIA_GALLEY_IMAGES . "/uid={$this->subject}";
             break;
     }
     //even if we got more media, we can display only 6
     $pictures = array();
     $max = count($pic) < 6 ? count($pic) : ($max = 6);
     for ($i = 0; $i < $max; $i++) {
         $pictures[$i] = $pic[$i];
     }
     $audios = array();
     $max = count($aud) < 6 ? count($aud) : ($max = 6);
     for ($i = 0; $i < $max; $i++) {
         $audios[$i] = $aud[$i];
     }
     $videos = array();
     $max = count($vid) < 6 ? count($vid) : ($max = 6);
     for ($i = 0; $i < $max; $i++) {
         $videos[$i] = $vid[$i];
     }
     if (!empty($this->group_details) && (!empty($pictures) || !empty($audios) || !empty($videos))) {
         $this->view_all_url = PA::$url . PA_ROUTE_MEDIA_GALLEY_IMAGES . "/view=groups_media&gid=" . (int) $this->group_details->collection_id;
     }
     $gallery = array('images' => $pictures, 'audios' => $audios, 'videos' => $videos);
     $this->links = $gallery;
     $this->inner_HTML = $this->generate_inner_html($this->links);
     if (empty($gallery['images']) && empty($gallery['audios']) && empty($gallery['videos'])) {
         $this->height = 70;
         $this->view_all_url = '';
     } else {
         $this->height = 260;
     }
     $content = parent::render();
     return $content;
 }
コード例 #4
0
function peopleaggregator_getFiles($args)
{
    $user = User::from_auth_token($args['authToken']);
    $context = $args['context'];
    $files_out = array();
    // When uploading a file, we can use the special 'default album' context: 'user:123:album:default:image'
    if (preg_match("/^user:\\d+:album:default:[a-z]+\$/", $context)) {
        // no files - this album doesn't exist yet
    } else {
        list($collection_id, $album) = api_validate_album_context($context, $user, "read");
        foreach (array(array("audio", Audio::load_audios_for_collection_id($collection_id, 0, "C.created")), array("image", Image::load_images_for_collection_id($collection_id, 0, "C.created")), array("video", Video::load_videos_for_collection_id($collection_id, 0, "C.created"))) as $bits) {
            list($type, $files) = $bits;
            if ($files) {
                foreach ($files as $c) {
                    $filename = $c[$type . '_file'];
                    $file_out = array('id' => "file:" . $c['content_id'], 'created' => $c['created'], 'title' => $c['title'], 'content' => $c['body'], 'type' => $type, 'author' => "user:"******"|^http://|", $filename)) {
                        $file_out['url'] = $filename;
                    } else {
                        $full_path = PA::$upload_path . '/' . $filename;
                        if (file_exists($full_path)) {
                            $file_out['url'] = api_get_url_of_file($filename);
                            if ($type == 'image') {
                                list($file_out['width'], $file_out['height']) = getimagesize($full_path);
                            }
                        }
                    }
                    $files_out[] = $file_out;
                }
            }
        }
    }
    return array('success' => TRUE, 'files' => $files_out);
}
コード例 #5
0
 function render()
 {
     $pictures = array();
     $audios = array();
     $videos = array();
     global $base_url, $login_uid;
     $uid_gal = $this->uid;
     if (!empty($uid_gal)) {
         $this->view_all_url = "{$base_url}/media_gallery.php?uid={$uid_gal}";
     }
     if ($this->page == 'homepage') {
         if (isset($_SESSION['user']['id'])) {
             $my_id = $_SESSION['user']['id'];
             $this->uid = $_SESSION['user']['id'];
         } else {
             $my_id = 0;
         }
         if ($this->uid) {
             $u_id = $this->uid;
         } else {
             $u_id = 0;
         }
         $pic = Image::load_recent_media_image(0, $my_id);
         $aud = Audio::load_recent_media_audio(0, $my_id);
         $vid = Video::load_recent_media_video(0, $my_id);
         //even if we got more media, we can display only 6
         if (count($pic) < 6) {
             $max = count($pic);
         } else {
             $max = 6;
         }
         $pictures = array();
         for ($i = 0; $i < $max; $i++) {
             $pictures[$i] = $pic[$i];
         }
         if (count($aud) < 6) {
             $max = count($aud);
         } else {
             $max = 6;
         }
         for ($i = 0; $i < $max; $i++) {
             $audios[$i] = $aud[$i];
         }
         if (count($vid) < 6) {
             $max = count($vid);
         } else {
             $max = 6;
         }
         for ($i = 0; $i < $max; $i++) {
             $videos[$i] = $vid[$i];
         }
     } else {
         if ($this->page == 'grouppage') {
             $pic = Image::load_images_for_collection_id((int) $this->group_details['collection_id']);
             $aud = Audio::load_audios_for_collection_id((int) $this->group_details['collection_id']);
             //$this->links = $audios;
             $vid = Video::load_videos_for_collection_id((int) $this->group_details['collection_id']);
             if (count($pic) < 6) {
                 $max = count($pic);
             } else {
                 $max = 6;
             }
             for ($i = 0; $i < $max; $i++) {
                 $pictures[$i] = $pic[$i];
             }
             if (count($aud) < 6) {
                 $max = count($aud);
             } else {
                 $max = 6;
             }
             for ($i = 0; $i < $max; $i++) {
                 $audios[$i] = $aud[$i];
             }
             if (count($vid) < 6) {
                 $max = count($vid);
             } else {
                 $max = 6;
             }
             for ($i = 0; $i < $max; $i++) {
                 $videos[$i] = $vid[$i];
             }
         } else {
             $pic = Image::load_images($this->uid, 10, $login_uid);
             //$this->links = $pictures;
             $aud = Audio::load_audio($this->uid, 10, $login_uid);
             //$this->links = $audios;
             $vid = Video::load_video($this->uid, 10, $login_uid);
             if (count($pic) < 6) {
                 $max = count($pic);
             } else {
                 $max = 6;
             }
             for ($i = 0; $i < $max; $i++) {
                 $pictures[$i] = $pic[$i];
             }
             if (count($aud) < 6) {
                 $max = count($aud);
             } else {
                 $max = 6;
             }
             for ($i = 0; $i < $max; $i++) {
                 $audios[$i] = $aud[$i];
             }
             if (count($vid) < 6) {
                 $max = count($vid);
             } else {
                 $max = 6;
             }
             for ($i = 0; $i < $max; $i++) {
                 $videos[$i] = $vid[$i];
             }
         }
     }
     if (!empty($this->group_details) && (!empty($pictures) || !empty($audios) || !empty($videos))) {
         $this->view_all_url = "{$base_url}/group_media_gallery.php?gid=" . (int) $this->group_details['collection_id'];
     }
     if (!empty($this->group_details)) {
         $this->gid = $this->group_details['collection_id'];
     }
     $gallery = array('images' => $pictures, 'audios' => $audios, 'videos' => $videos);
     $this->links = $gallery;
     $this->inner_HTML = $this->generate_inner_html($this->links);
     if (empty($gallery['images']) && empty($gallery['audios']) && empty($gallery['videos'])) {
         $this->height = 70;
         $this->view_all_url = '';
     } else {
         $this->height = 260;
     }
     $content = parent::render();
     return $content;
 }