示例#1
0
文件: profile.php 项目: emnaborgi/RS
</span>

                    <form id="upload-photo" style="display:none;" method="post" enctype="multipart/form-data">
                        <input type="file" name="userphoto" class="pfile"
                               onchange="Ossn.Clk('#upload-photo .upload');"/>
                         <?php 
    echo ossn_plugin_view('input/security_token');
    ?>
      
                        <input type="submit" class="upload"/>
                    </form>
                </div>
            <?php 
}
$viewer = '';
if (ossn_isLoggedIn() && get_profile_photo_guid($user->guid)) {
    $viewer = 'onclick="Ossn.Viewer(\'photos/viewer?user='******'\');"';
}
?>
            <img src="<?php 
echo $user->iconURL()->larger;
?>
" height="170" width="170" <?php 
echo $viewer;
?>
 />
        </div>
        <div class="profile-name"><?php 
echo $user->fullname;
?>
</div>
/**
 * Ossn Photos page handler
 * @pages:
 *       view,
 *    user,
 *       add,
 *       viewer
 *
 * @return mixed contents
 */
function ossn_photos_page_handler($album)
{
    $page = $album[0];
    if (empty($page)) {
        ossn_error_page();
    }
    switch ($page) {
        case 'view':
            if (isset($album[1])) {
                $title = ossn_print('photos');
                $photo['photo'] = $album[1];
                $view = new OssnPhotos();
                $image = $view->GetPhoto($photo['photo']);
                $photo['entity'] = $image;
                //redirect user to home page if image is empty
                if (empty($image)) {
                    redirect();
                }
                //throw 404 page if there is no album access
                $albumget = ossn_albums();
                $owner = $albumget->GetAlbum($image->owner_guid)->album;
                if ($owner->access == 3) {
                    if (!ossn_validate_access_friends($owner->owner_guid)) {
                        ossn_error_page();
                    }
                }
                //shows widget back button
                $addphotos = array('text' => ossn_print('back'), 'href' => 'javascript::;', 'class' => 'button-grey');
                $control = ossn_plugin_view('output/url', $addphotos);
                $contents = array('title' => ossn_print('photos'), 'content' => ossn_plugin_view('photos/pages/photo/view', $photo), 'controls' => $control);
                //set page layout
                $module['content'] = ossn_set_page_layout('media', $contents);
                $content = ossn_set_page_layout('contents', $module);
                echo ossn_view_page($title, $content);
            }
            break;
        case 'user':
            if (isset($album[1]) && isset($album[2]) && $album[1] == 'view') {
                $title = ossn_print('photos');
                $photo['photo'] = $album[2];
                $type = input('type');
                $view = new OssnPhotos();
                $image = $view->GetPhoto($photo['photo']);
                $photo['entity'] = $image;
                //redirect user if photo is empty
                if (empty($image->value)) {
                    redirect();
                }
                $addphotos = array('text' => ossn_print('back'), 'href' => 'javascript::;', 'class' => 'button-grey');
                $control = ossn_plugin_view('output/url', $addphotos);
                $contents = array('title' => 'Photos', 'content' => ossn_plugin_view('photos/pages/profile/photos/view', $photo), 'controls' => $control);
                //set page layout
                $module['content'] = ossn_set_page_layout('media', $contents);
                $content = ossn_set_page_layout('contents', $module);
                echo ossn_view_page($title, $content);
            }
            break;
        case 'cover':
            if (isset($album[1]) && isset($album[2]) && $album[1] == 'view') {
                $title = ossn_print('cover:view');
                $photo['photo'] = $album[2];
                $type = input('type');
                $image = ossn_get_entity($photo['photo']);
                $photo['entity'] = $image;
                //redirect user if photo is empty
                if (empty($image->value)) {
                    redirect();
                }
                $addphotos = array('text' => ossn_print('back'), 'href' => 'javascript::;', 'class' => 'button-grey');
                $control = ossn_plugin_view('output/url', $addphotos);
                $contents = array('title' => 'Photos', 'content' => ossn_plugin_view('photos/pages/profile/covers/view', $photo), 'controls' => $control);
                //set page layout
                $module['content'] = ossn_set_page_layout('media', $contents);
                $content = ossn_set_page_layout('contents', $module);
                echo ossn_view_page($title, $content);
            }
            break;
        case 'add':
            //add photos (ajax)
            if (!ossn_is_xhr()) {
                ossn_error_page();
            }
            echo ossn_plugin_view('output/ossnbox', array('title' => ossn_print('add:photos'), 'contents' => ossn_plugin_view('photos/pages/photos/add'), 'callback' => '#ossn-photos-submit'));
            break;
        case 'viewer':
            //ossn image viewer currently works for profile images
            $image = input('user');
            $url = ossn_site_url("avatar/{$image}");
            $media = "<img src='{$url}' />";
            $photo_guid = get_profile_photo_guid(ossn_user_by_username($image)->guid);
            //set viewer sidebar (comments and likes)
            $sidebar = ossn_plugin_view('photos/viewer/comments', array('entity_guid' => $photo_guid));
            echo ossn_plugin_view('output/viewer', array('media' => $media, 'sidebar' => $sidebar));
            break;
        default:
            ossn_error_page();
            break;
    }
}