-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eric Vieira de Souza
committed
Nov 26, 2012
0 parents
commit 0acae14
Showing
27 changed files
with
1,588 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* Delete a media | ||
* | ||
* @package medias | ||
*/ | ||
|
||
$guid = get_input('guid'); | ||
$media = get_entity($guid); | ||
|
||
if (elgg_instanceof($media, 'object', 'medias') && $media->canEdit()) { | ||
$container = $media->getContainerEntity(); | ||
if ($media->delete()) { | ||
system_message(elgg_echo("medias:delete:success")); | ||
if (elgg_instanceof($container, 'group')) { | ||
forward("medias/group/$container->guid/all"); | ||
} else { | ||
forward("medias/owner/$container->username"); | ||
} | ||
} | ||
} | ||
|
||
register_error(elgg_echo("medias:delete:failed")); | ||
forward(REFERER); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?php | ||
/** | ||
* Elgg medias save action | ||
* | ||
* @package medias | ||
*/ | ||
|
||
gatekeeper(); | ||
|
||
$title = strip_tags(get_input('title')); | ||
$description = get_input('description'); | ||
$address = get_input('address'); | ||
$access_id = get_input('access_id'); | ||
$tags = get_input('tags'); | ||
$guid = get_input('guid'); | ||
$share = get_input('share'); | ||
$container_guid = get_input('container_guid', elgg_get_logged_in_user_guid()); | ||
|
||
elgg_make_sticky_form('medias'); | ||
|
||
//embedly api Authentication | ||
require_once (dirname(dirname(dirname(__FILE__)))) . '/lib/Embedly.php'; | ||
|
||
$projectapp = $site->sitename; | ||
$contactapp = $site->siteemail; | ||
$api = new Embedly_API(array( | ||
'user_agent' => 'Mozilla/5.0 (compatible; '. $projectapp .'/elgg; '. $contactapp .')' | ||
)); | ||
|
||
//embedly api Data | ||
$oembeds = $api->oembed(array('url' => $address)); | ||
// | ||
|
||
// don't use elgg_normalize_url() because we don't want | ||
// relative links resolved to this site. | ||
if ($address && !preg_match("#^((ht|f)tps?:)?//#i", $address)) { | ||
$address = "http://$address"; | ||
} | ||
|
||
//noelab: don't control title | ||
if (!$address || !filter_var($address, FILTER_VALIDATE_URL)) { | ||
register_error(elgg_echo('medias:save:failed')); | ||
forward(REFERER); | ||
} | ||
|
||
if ($guid == 0) { | ||
$media = new ElggObject; | ||
$media->subtype = "medias"; | ||
$media->container_guid = (int)get_input('container_guid', $_SESSION['user']->getGUID()); | ||
$new = true; | ||
} else { | ||
$media = get_entity($guid); | ||
if (!$media->canEdit()) { | ||
system_message(elgg_echo('medias:save:failed')); | ||
forward(REFERRER); | ||
} | ||
} | ||
|
||
$tagarray = string_to_tag_array($tags); | ||
|
||
//noelab embedly | ||
$entity->address = $address; | ||
|
||
//embedly api Values | ||
foreach ($oembeds as $k => $oembed) { | ||
$oembed = (array) $oembed; | ||
|
||
//embedly api Save | ||
$media->oembed_html = $oembed['html']; | ||
$media->oembed_type = $oembed['type']; | ||
$media->oembedtitle = $oembed['title']; | ||
$media->oembed_url = $oembed['url']; | ||
$media->oembed_author_name = $oembed['author_name']; | ||
$media->oembed_description = $oembed['description']; | ||
//$media->oembed_author_url= $oembed['author_url']; | ||
$media->oembed_provider_name = $oembed['provider_name']; | ||
//$media->mediaprovider_url = $oembed['provider_url']; | ||
$media->oembed_thumbnail_url = $oembed['thumbnail_url']; | ||
$media->oembed_thumbnail_width = $oembed['thumbnail_width']; | ||
$media->oembed_thumbnail_height = $oembed['thumbnail_height']; | ||
|
||
|
||
} | ||
|
||
if(!$title) { | ||
$title = $media->oembedtitle; | ||
} | ||
|
||
$media->title = $title; | ||
$media->address = $address; | ||
$media->description = $description; | ||
$media->access_id = $access_id; | ||
$media->tags = $tagarray; | ||
|
||
if ($media->save()) { | ||
|
||
elgg_clear_sticky_form('medias'); | ||
|
||
// @todo | ||
if (is_array($shares) && sizeof($shares) > 0) { | ||
foreach($shares as $share) { | ||
$share = (int) $share; | ||
add_entity_relationship($media->getGUID(), 'share', $share); | ||
} | ||
} | ||
system_message(elgg_echo('medias:save:success')); | ||
|
||
//add to river only if new | ||
if ($new) { | ||
add_to_river('river/object/medias/create','create', elgg_get_logged_in_user_guid(), $media->getGUID()); | ||
} | ||
|
||
forward($media->getURL()); | ||
} else { | ||
register_error(elgg_echo('medias:save:failed')); | ||
forward("medias"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/** | ||
* medias English language file | ||
*/ | ||
|
||
$english = array( | ||
|
||
/** | ||
* Menu items and titles | ||
*/ | ||
'medias' => "Medias", | ||
'medias:add' => "Add Media", | ||
'medias:edit' => "Edit Media", | ||
'medias:owner' => "%s's Medias", | ||
'medias:friends' => "Friends' Medias", | ||
'medias:everyone' => "All site Medias", | ||
'medias:this:group' => "Media in %s", | ||
'medias:inbox' => "Medias inbox", | ||
'medias:moremedias' => "More Medias", | ||
'medias:more' => "More", | ||
'medias:with' => "Share with", | ||
'medias:new' => "A new media", | ||
'medias:via' => "via medias", | ||
'medias:address' => "Address of the resource to media", | ||
'medias:none' => 'No medias', | ||
|
||
'medias:delete:confirm' => "Are you sure you want to delete this resource?", | ||
|
||
'medias:numbertodisplay' => 'Number of medias to display', | ||
|
||
'medias:shared' => "shared", | ||
'medias:visit' => "Visit resource", | ||
'medias:recent' => "Recent medias", | ||
|
||
'river:create:object:medias' => '%s shared %s', | ||
'river:comment:object:medias' => '%s commented on a media %s', | ||
'medias:river:annotate' => 'a comment on this media', | ||
'medias:river:item' => 'an item', | ||
|
||
'item:object:medias' => 'medias', | ||
|
||
'medias:group' => 'Group medias', | ||
'medias:enablemedias' => 'Enable group medias', | ||
'medias:nogroup' => 'This group does not have any medias yet', | ||
'medias:more' => 'More medias', | ||
|
||
'medias:no_title' => 'No title', | ||
|
||
/** | ||
* Widget | ||
*/ | ||
'medias:widget:description' => "Display your latest medias.", | ||
|
||
|
||
/** | ||
* Status messages | ||
*/ | ||
|
||
'medias:save:success' => "Your item was successfully posted.", | ||
'medias:delete:success' => "Your media item was successfully deleted.", | ||
|
||
/** | ||
* Error messages | ||
*/ | ||
|
||
'medias:save:failed' => "Your media could not be saved. Make sure you've entered a title and address and then try again.", | ||
'medias:delete:failed' => "Your media could not be deleted. Please try again.", | ||
|
||
/** | ||
* Oembed Metadata | ||
*/ | ||
|
||
'mediaembedly:aboutitem' => "About this Media", | ||
'mediaembedly:mediaauthor' => 'Published by', | ||
); | ||
|
||
add_translation('en', $english); |
Oops, something went wrong.