Esempio n. 1
0
	/**
	* Get the file from the specified path
	*
	* @param string $path The path of the file to retrieve
	* @param array $qualities Qualities that specify the version of the file to retrieve.
	* @return MediaAsset The requested asset
	*/
	public function silo_get( $path, $qualities = null )
	{
		$flickr = new Flickr();
		$results = array();
		$size = Options::get( 'flickrsilo__flickr_size' );
		list($unused, $photoid) = explode( '/', $path );
		
		$xml = $flickr->photosGetInfo($photoid);
		$photo = $xml->photo;

		$props = array();
		foreach( $photo->attributes() as $name => $value ) {
			$props[$name] = (string)$value;
		}
		$props = array_merge( $props, self::element_props( $photo, "http://www.flickr.com/photos/{$_SESSION['nsid']}/{$photo['id']}", $size ) );
		$result = new MediaAsset(
			self::SILO_NAME . '/photos/' . $photo['id'],
			false,
			$props
		);

		return $result;
	}
Esempio n. 2
0
    public function filter_shortcode_flickr($code_to_replace, $code_name, $attr_array, $code_contents, $post)
    {
        $id = $attr_array['id'];
        $size = isset($attr_array['size']) ? '_' . $attr_array['size'] : Options::get('flickrsilo__flickr_size');
        $info = "flickr{$id}";
        $flickr = $post->info->{$info};
        $f = new Flickr(array('user_id' => $post->author->id));
        if (!$flickr) {
            // this photo's details aren't cached on this post. Let's grab 'em
            $xml = $f->photosGetInfo($id);
            if (!$xml->photo) {
                return $code_to_replace;
            }
            // get an array of the 'photo' element from the XML
            $p = (array) $xml->photo->attributes();
            $flickr = $p['@attributes'];
            // stuff in the URL to the photopage
            $flickr['photopage'] = (string) $xml->photo->urls[0]->url[0];
            // and if it's a video, we want its dimensions
            if ('video' == $flickr['media']) {
                if (0 == $xml->photo->video['ready']) {
                    return $code_to_replace;
                }
                $flickr['height'] = (string) $xml->photo->video->attributes()->height;
                $flickr['width'] = (string) $xml->photo->video->attributes()->width;
            }
            // cache this array on this post
            $post->info->{$info} = $flickr;
            $post->update();
        }
        if ('photo' == $flickr['media']) {
            $markup = '<a href="' . $flickr['photopage'] . '">';
            $markup .= '<img src="';
            $markup .= $f->getPhotoURL($flickr, $size);
            $markup .= '"';
            if (isset($attr_array['class'])) {
                $markup .= ' class="' . $attr_array['class'] . '"';
            }
            $markup .= '></a>';
        } else {
            $photo_id = $flickr['id'];
            $secret = $flickr['secret'];
            $height = $flickr['height'];
            $width = $flickr['width'];
            $markup = <<<EOF
<object type="application/x-shockwave-flash" width="{$width}" height="{$height}" data="//www.flickr.com/apps/video/stewart.swf?v=109786"  classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="flashvars" value="intl_lang=en-us&photo_secret={$secret}&photo_id={$id}&flickr_show_info_box=true&hd_default=false"></param> <param name="movie" value="//www.flickr.com/apps/video/stewart.swf?v=109786"></param><param name="bgcolor" value="#000000"></param><param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="//www.flickr.com/apps/video/stewart.swf?v=109786" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&photo_secret={$secret}&photo_id={$id}&flickr_show_info_box=true&hd_default=false" height="{$height}" width="{$width}"></embed></object>
EOF;
        }
        return $markup;
    }