case 'TekVideo':
       $show_media = new TekVideo();
   break;
   default:
       die("Content ID $cid is non-media (not image, audio, or video)");
   break;
 }
 $show_media->load($cid);
 switch ($content_info->type) {
   case 'Audio':
     if (strstr($show_media->file_name, "http://")) {
       $src = $show_media->file_name;
       $file = $show_media->file_name;
     } else {
       $file = $show_media->file_name;
       $src = Storage::getURL($file);
     }
     $media_value = $show_media->file_name;
     $default_icon = uihelper_resize_mk_img(null, 86, 92, 'images/default_audio.png', "", RESIZE_CROP);
   break;
   case 'TekVideo':
     $image_show = '<script src="'.PA::$tekmedia_site_url.'/Integration/remotePlayer.php?video_id='.$show_media->video_id.'&preroll=true"></script>';
     $default_icon = uihelper_resize_mk_img(null, 86, 92, 'images/default_video.png', "", RESIZE_CROP);
     $media_value = $show_media->video_id;
   break;
   case 'Image':
     if (strstr($show_media->image_file, "http://")) {
       $tt = $show_media->image_file;
         $image_show = getimagehtml($tt, 86, 92, "", $tt);
         $media_value = $show_media->file_name;
     } else {
Esempio n. 2
0
 function testStorage()
 {
     // test Storage - public API
     // store test.txt
     echo "saving test.txt with a crazy name\n";
     $file_id = Storage::save('test.txt', 'O*Bc3wukygfsT@#($0876)$!@#*+_][.txt');
     echo "resulting file_id = {$file_id}\n";
     $file = Dal::query_one_object("SELECT * FROM files WHERE file_id=?", array($file_id));
     $this->assertEquals($file->link_count, 0);
     $this->assertEquals($file->last_linked, NULL);
     $file_path = Storage::getPath($file_id);
     $file_url = Storage::getURL($file_id);
     echo "getPath({$file_id}) -> {$file_path}\n";
     echo "getURL({$file_id}) -> {$file_url}\n";
     $this->assertTrue(strpos($file_path, PA::$path . "/web/files/") === 0);
     $this->assertTrue(strpos($file_url, PA::$url) === 0);
     // link it in somewhere
     $link_id = Storage::link($file_id, array('role' => 'avatar', 'user' => 1));
     echo "linked it in as avatar for user 1; link_id = {$link_id}\n";
     $link = Dal::query_one_object("SELECT * FROM file_links WHERE link_id=?", array($link_id));
     $this->assertEquals($link->file_id, $file_id);
     $file = Dal::query_one_object("SELECT * FROM files WHERE file_id=?", array($file_id));
     $this->assertEquals($file->link_count, 1);
     $this->assertNotEquals($file->last_linked, NULL);
     // another file
     $child_file_id = Storage::save('test2.txt', 'this is the child file.jpg', 'throwaway', 'image/jpeg');
     echo "child file: {$child_file_id}\n";
     $child_file = Dal::query_one_object("SELECT * FROM files WHERE file_id=?", array($child_file_id));
     $child_file_path = Storage::getPath($child_file_id);
     $child_file_url = Storage::getURL($child_file_id);
     echo "getPath({$child_file_id}) -> {$child_file_path}\n";
     echo "getURL({$child_file_id}) -> {$child_file_url}\n";
     $this->assertTrue(strpos($child_file_path, PA::$path . "/web/files/") === 0);
     $this->assertTrue(strpos($child_file_url, PA::$url) === 0);
     // link child file in as a thumbnail of first file
     $child_link_id = Storage::link($child_file_id, array('role' => 'thumb', 'file' => $file_id, 'dim' => '123x123'));
     echo "child link id: {$child_link_id}\n";
     $child_link = Dal::query_one_object("SELECT * FROM file_links WHERE link_id=?", array($child_link_id));
     $this->assertEquals($child_link->file_id, $child_file_id);
     $this->assertEquals($child_link->parent_file_id, $file_id);
     $child_file = Dal::query_one_object("SELECT * FROM files WHERE file_id=?", array($child_file_id));
     $this->assertEquals($child_file->link_count, 1);
     $this->assertNotEquals($child_file->last_linked, NULL);
     // this should fail (missing role)
     try {
         Storage::link($file_id, array("user" => 1));
         $this->fail("Expected exception");
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), BAD_PARAMETER);
     }
     // this should fail (missing network)
     try {
         Storage::link($file_id, array("role" => "header", "group" => 42));
         $this->fail("Expected exception");
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), BAD_PARAMETER);
     }
     // this should fail (network not valid)
     try {
         Storage::link($file_id, array("role" => "thumb", "network" => 1, "file" => $file_id, "dim" => "123x123"));
         $this->fail("Expected exception");
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), BAD_PARAMETER);
     }
     // this should fail (parent_file_id == file_id)
     try {
         $link_id = Storage::link($file_id, array("role" => "thumb", "file" => $file_id, "dim" => "123x123"));
         $this->fail("Expected exception");
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), BAD_PARAMETER);
     }
     // Now unlink the two files we just created ...
     // unlink the first - but don't delete it
     Storage::unlink($file_id, $link_id, FALSE);
     // make sure it's gone
     $this->assertEquals(Dal::query_one("SELECT * FROM file_links WHERE link_id=?", array($link_id)), NULL);
     // the file should still be there, with zero links, though
     $file = Dal::query_one("SELECT * FROM files WHERE file_id=?", array($file_id));
     $this->assertNotEquals($file, NULL);
     $this->assertEquals($file->link_count, 0);
     // try a bad unlink operation
     try {
         Storage::unlink($file_id, $child_link_id);
         $this->fail("Expected exception");
     } catch (PAException $e) {
         $this->assertEquals($e->getCode(), FILE_NOT_FOUND);
     }
     // unlink and delete the second
     Storage::unlink($child_file_id, $child_link_id);
     // make sure it's gone
     $this->assertEquals(Dal::query_one("SELECT * FROM file_links WHERE link_id=?", array($child_link_id)), NULL);
     // and make sure the file is gone too
     $this->assertEquals(Dal::query_one("SELECT * FROM files WHERE file_id=?", array($child_file)), NULL);
     // reap unlinked files (immediately - no grace period)
     Storage::cleanupFiles(-1, -1);
     // make sure the first file is now gone
     $this->assertEquals(Dal::query_one("SELECT * FROM files WHERE file_id=?", array($file_id)), NULL);
 }
function api_resize_user_image($picture, $imageWidth, $imageHeight)
{
    $picture = trim($picture);
    if (empty($picture)) {
        return NULL;
    }
    // ripped off from web/includes/image_resize.php (uihelper_preprocess_pic_path)
    if (defined("NEW_STORAGE") && preg_match("|^pa://|", $picture)) {
        $picture = Storage::get($picture);
    } else {
        $picture = "files/{$picture}";
        if (!file_exists(PA::$project_dir . "/web/{$picture}") && !file_exists(PA::$core_dir . "/web/{$picture}")) {
            return NULL;
        }
    }
    if ($imageWidth) {
        // scale image down
        $im_info = ImageResize::resize_img("web", PA::$url, "files/rsz", $imageWidth, $imageHeight, $picture);
    } else {
        $im_size = @getimagesize(Storage::getPath($picture));
        $im_info = array('url' => Storage::getURL($picture), 'width' => $im_size[0], 'height' => $im_size[1]);
    }
    return array('url' => $im_info['url'], 'height' => (int) $im_info['height'], 'width' => (int) $im_info['width']);
}
  <foaf:givenname><?php 
echo esc($user->first_name);
?>
</foaf:givenname>
  <foaf:family_name><?php 
echo esc($user->last_name);
?>
</foaf:family_name>
  <foaf:nick><?php 
echo esc($user->login_name);
?>
</foaf:nick>
  <foaf:mbox_sha1sum><?php 
echo sha1($user->email);
?>
</foaf:mbox_sha1sum>
<? if (array_key_exists("blog_url", $user_generaldata)) { ?>
  <foaf:weblog rdf:resource="<?php 
echo esc($user_generaldata['blog_url']['value']);
?>
"/>
<? } ?>
<? if ($user->picture) { ?>
  <foaf:depiction rdf:resource="<?php 
echo esc(Storage::getURL($user->picture));
?>
"/>
<? } ?>
 </foaf:Person>
</rdf:RDF>