aboutsummaryrefslogtreecommitdiff
path: root/mod/file
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-03 22:13:10 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-03 22:13:10 +0000
commiteff4faea7f3c95440f02ea45d0be4f67236e2bf3 (patch)
tree57d51ef4bc84547d60c9a6faae7d5ff5d82d00f9 /mod/file
parent4b501dda1d62195531e4c2ab1bd84971c0cd4e37 (diff)
downloadelgg-eff4faea7f3c95440f02ea45d0be4f67236e2bf3.tar.gz
elgg-eff4faea7f3c95440f02ea45d0be4f67236e2bf3.tar.bz2
Fixes #1320: Bundled mods use elgg_echo()'s internal string substitution.
git-svn-id: http://code.elgg.org/elgg/trunk@7229 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/file')
-rw-r--r--mod/file/friends.php22
-rw-r--r--mod/file/index.php18
-rw-r--r--mod/file/search.php24
-rw-r--r--mod/file/start.php142
-rw-r--r--mod/file/views/default/object/file.php84
-rw-r--r--mod/file/views/default/river/object/file/create.php6
6 files changed, 148 insertions, 148 deletions
diff --git a/mod/file/friends.php b/mod/file/friends.php
index f76c4e692..895105480 100644
--- a/mod/file/friends.php
+++ b/mod/file/friends.php
@@ -1,40 +1,40 @@
<?php
/**
* Elgg file browser
- *
+ *
* @package ElggFile
*/
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
+
if (is_callable('group_gatekeeper')) {
group_gatekeeper();
}
-
+
$owner = elgg_get_page_owner();
-
- $title = sprintf(elgg_echo("file:friends"),$owner->name);
- $area1 = elgg_view('page_elements/content_header', array('context' => "friends", 'type' => 'file'));
+
+ $title = elgg_echo("file:friends",array($owner->name));
+ $area1 = elgg_view('page_elements/content_header', array('context' => "friends", 'type' => 'file'));
elgg_push_context('search');
// offset is grabbed in list_user_friends_objects
$content = list_user_friends_objects($owner->guid, 'file', 10, false);
elgg_pop_context();
$area1 .= get_filetype_cloud($owner->guid, true);
-
+
// handle case where friends don't have any files
if (empty($content)) {
$area2 .= "<p class='margin_top'>".elgg_echo("file:none")."</p>";
} else {
$area2 .= $content;
}
-
+
//get the latest comments on all files
$comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc");
- $area3 = elgg_view('annotation/latest_comments', array('comments' => $comments));
-
+ $area3 = elgg_view('annotation/latest_comments', array('comments' => $comments));
+
$content = "<div class='files'>".$area1.$area2."</div>";
$body = elgg_view_layout('one_column_with_sidebar', $content, $area3);
-
+
echo elgg_view_page($title, $body);
?> \ No newline at end of file
diff --git a/mod/file/index.php b/mod/file/index.php
index 2a82ee1e4..21d573b2b 100644
--- a/mod/file/index.php
+++ b/mod/file/index.php
@@ -1,10 +1,10 @@
<?php
/**
* Elgg file browser
- *
+ *
* @package ElggFile
- *
- *
+ *
+ *
* TODO: File icons, download & mime types
*/
@@ -12,16 +12,16 @@
// access check for closed groups
group_gatekeeper();
-
+
//set the title
if (elgg_get_page_owner_guid() == get_loggedin_userid()) {
$title = elgg_echo('file:yours');
$area1 = elgg_view('page_elements/content_header', array('context' => "mine", 'type' => 'file'));
} else {
- $title = sprintf(elgg_echo("file:user"),elgg_get_page_owner()->name);
+ $title = elgg_echo("file:user",array(elgg_get_page_owner()->name));
$area1 = elgg_view('page_elements/content_header', array('context' => "friends", 'type' => 'file'));
}
-
+
// Get objects
elgg_push_context('search');
$offset = (int)get_input('offset', 0);
@@ -34,13 +34,13 @@
} else {
$area2 .= "<p class='margin_top'>".elgg_echo("file:none")."</p>";
}
-
+
//get the latest comments on the current users files
$comments = get_annotations(0, "object", "file", "generic_comment", "", 0, 4, 0, "desc",0,0,page_owner());
$area3 = elgg_view('annotation/latest_comments', array('comments' => $comments));
-
+
$content = "<div class='files'>".$area1.$area2."</div>";
$body = elgg_view_layout('one_column_with_sidebar', $content, $area3);
-
+
echo elgg_view_page($title, $body);
?> \ No newline at end of file
diff --git a/mod/file/search.php b/mod/file/search.php
index e92cf0362..b0120d932 100644
--- a/mod/file/search.php
+++ b/mod/file/search.php
@@ -2,7 +2,7 @@
/**
* Elgg file search
- *
+ *
* @package ElggFile
*/
@@ -10,7 +10,7 @@
// Load Elgg engine
require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
+
// Get input
$md_type = 'simpletype';
$tag = get_input('tag');
@@ -31,17 +31,17 @@
}
}
$page_owner = get_input('page_owner',0);
- if ($page_owner) {
+ if ($page_owner) {
set_page_owner($page_owner);
} else {
if ($friends) {
- set_page_owner($friends);
+ set_page_owner($friends);
} else {
if ($owner_guid > 0 && !is_array($owner_guid))
set_page_owner($owner_guid);
}
}
-
+
if (is_callable('group_gatekeeper')) group_gatekeeper();
if (empty($tag)) {
@@ -49,12 +49,12 @@
$area2 = elgg_view_title(elgg_echo('file:type:all'));
$area2 = elgg_view('page_elements/content_header', array('context' => "everyone", 'type' => 'file'));
} else {
- $title = sprintf(elgg_echo('searchtitle'),$tag);
+ $title = elgg_echo('searchtitle',array($tag));
if (is_array($owner_guid)) {
//$area2 = elgg_view_title(elgg_echo("file:friends:type:" . $tag));
$area2 = elgg_view('page_elements/content_header', array('context' => "friends", 'type' => 'file'));
} else if (elgg_get_page_owner_guid() && elgg_get_page_owner_guid() != get_loggedin_userid()) {
- //$area2 = elgg_view_title(sprintf(elgg_echo("file:user:type:" . $tag),elgg_get_page_owner()->name));
+ //$area2 = elgg_view_title(elgg_echo("file:user:type:" . $tag,array(elgg_get_page_owner()->name)));
$area2 = elgg_view('page_elements/content_header', array('context' => "mine", 'type' => 'file'));
} else{
//$area2 = elgg_view_title(elgg_echo("file:type:" . $tag));
@@ -68,7 +68,7 @@
} else {
$area1 = get_filetype_cloud();
}
-
+
elgg_push_context('search');
$offset = (int)get_input('offset', 0);
@@ -87,13 +87,13 @@
} else {
$area2 .= elgg_list_entities(array('types' => 'object', 'subtypes' => 'file', 'owner_guid' => $owner_guid, 'limit' => $limit, 'offset' => $offset));
}
-
+
elgg_pop_context();
-
+
$content = "<div class='files'>".$area1.$area2."</div>";
-
+
$body = elgg_view_layout('one_column_with_sidebar', $content);
-
+
echo elgg_view_page($title, $body);
?> \ No newline at end of file
diff --git a/mod/file/start.php b/mod/file/start.php
index 3d66dcc21..64e890626 100644
--- a/mod/file/start.php
+++ b/mod/file/start.php
@@ -1,50 +1,50 @@
<?php
/**
* Elgg file browser
- *
+ *
* @package ElggFile
*/
/**
- * Override the ElggFile so that
+ * Override the ElggFile so that
*/
class FilePluginFile extends ElggFile {
protected function initialise_attributes() {
parent::initialise_attributes();
-
+
$this->attributes['subtype'] = "file";
}
-
- public function __construct($guid = null) {
+
+ public function __construct($guid = null) {
parent::__construct($guid);
}
}
-
+
/**
* File plugin initialisation functions.
*/
function file_init() {
global $CONFIG;
-
+
// Set up menu (tools dropdown)
add_menu(elgg_echo('files'), "pg/file/");
-
+
// Extend CSS
elgg_extend_view('css', 'file/css');
-
- // extend group main page
+
+ // extend group main page
elgg_extend_view('groups/tool_latest','file/groupprofile_files');
-
+
// Register a page handler, so we can have nice URLs
register_page_handler('file','file_page_handler');
-
+
// Add a new file widget
add_widget_type('filerepo',elgg_echo("file"),elgg_echo("file:widget:description"));
-
+
// Register a URL handler for files
register_entity_url_handler('file_url','object','file');
-
+
// Register granular notification for this object type
if (is_callable('register_notification_object')) {
register_notification_object('object', 'file', elgg_echo('file:newupload'));
@@ -52,8 +52,8 @@
// Listen to notification events and supply a more useful message
register_plugin_hook('notify:entity:message', 'object', 'file_notify_message');
-
- // add the group files tool option
+
+ // add the group files tool option
add_group_tool_option('file',elgg_echo('groups:enablefiles'),true);
// Register entity type
@@ -63,24 +63,24 @@
register_plugin_hook('embed_get_sections', 'all', 'file_embed_get_sections');
register_plugin_hook('embed_get_items', 'file', 'file_embed_get_items');
register_plugin_hook('embed_get_upload_sections', 'all', 'file_embed_get_upload_sections');
-
+
}
-
+
/**
* Sets up submenus for the file system. Triggered on pagesetup.
*
*/
function file_submenus() {
-
+
global $CONFIG;
-
+
$page_owner = elgg_get_page_owner();
-
- // Group submenu option
+
+ // Group submenu option
if ($page_owner instanceof ElggGroup && elgg_get_context() == "groups") {
- if($page_owner->file_enable != "no"){
- add_submenu_item(sprintf(elgg_echo("file:group"),$page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username);
- }
+ if($page_owner->file_enable != "no"){
+ add_submenu_item(elgg_echo("file:group",array($page_owner->name)), $CONFIG->wwwroot . "pg/file/" . $page_owner->username);
+ }
}
}
@@ -90,37 +90,37 @@
* @param array $page Array of page elements, forwarded by the page handling mechanism
*/
function file_page_handler($page) {
-
+
global $CONFIG;
-
+
// The username should be the file we're getting
if (isset($page[0])) {
set_input('username',$page[0]);
}
-
+
if (isset($page[1])) {
- switch($page[1]) {
- case "read":
- set_input('guid',$page[2]);
+ switch($page[1]) {
+ case "read":
+ set_input('guid',$page[2]);
include(dirname(dirname(dirname(__FILE__))) . "/pages/entities/index.php");
break;
- case "friends":
- include($CONFIG->pluginspath . "file/friends.php");
- break;
- case "world":
- include($CONFIG->pluginspath . "file/world.php");
- break;
- case "new":
- include($CONFIG->pluginspath . "file/upload.php");
- break;
- }
+ case "friends":
+ include($CONFIG->pluginspath . "file/friends.php");
+ break;
+ case "world":
+ include($CONFIG->pluginspath . "file/world.php");
+ break;
+ case "new":
+ include($CONFIG->pluginspath . "file/upload.php");
+ break;
+ }
} else {
// Include the standard profile index
include($CONFIG->pluginspath . "file/index.php");
}
-
+
}
-
+
/**
* Returns a more meaningful message
*
@@ -128,7 +128,7 @@
* @param unknown_type $entity_type
* @param unknown_type $returnvalue
* @param unknown_type $params
- */
+ */
function file_notify_message($hook, $entity_type, $returnvalue, $params) {
$entity = $params['entity'];
$to_entity = $params['to_entity'];
@@ -162,7 +162,7 @@
* @return string The overall type
*/
function get_general_file_type($mimetype) {
-
+
switch($mimetype) {
case "application/msword":
return "document";
@@ -171,34 +171,34 @@
return "document";
break;
}
-
+
if (substr_count($mimetype,'text/'))
return "document";
-
+
if (substr_count($mimetype,'audio/'))
return "audio";
-
+
if (substr_count($mimetype,'image/'))
return "image";
-
+
if (substr_count($mimetype,'video/'))
return "video";
if (substr_count($mimetype,'opendocument'))
- return "document";
-
- return "general";
+ return "document";
+
+ return "general";
}
-
+
/**
* Returns a list of filetypes to search specifically on
*
- * @param int|array $owner_guid The GUID(s) of the owner(s) of the files
+ * @param int|array $owner_guid The GUID(s) of the owner(s) of the files
* @param true|false $friends Whether we're looking at the owner or the owner's friends
* @return string The typecloud
*/
function get_filetype_cloud($owner_guid = "", $friends = false) {
-
+
if ($friends) {
if ($friendslist = get_user_friends($user_guid, "", 999999, 0)) {
$friendguids = array();
@@ -217,7 +217,7 @@
return elgg_view('file/typecloud',array('owner_guid' => $owner_guid, 'friend_guid' => $friendofguid, 'types' => $types));
}
-
+
/**
* Register file as an embed type.
*
@@ -232,10 +232,10 @@
'layout' => 'list',
'icon_size' => 'small',
);
-
+
return $value;
}
-
+
/**
* Return a list of files for embedding
*
@@ -250,22 +250,22 @@
'type_subtype_pair' => array('object' => 'file'),
'count' => TRUE
);
-
+
if ($count = elgg_get_entities($options)) {
$value['count'] += $count;
-
+
unset($options['count']);
$options['offset'] = $params['offset'];
$options['limit'] = $params['limit'];
-
+
$items = elgg_get_entities($options);
-
+
$value['items'] = array_merge($items, $value['items']);
}
-
+
return $value;
}
-
+
/**
* Register file as an embed type.
*
@@ -279,11 +279,11 @@
'name' => elgg_echo('file'),
'view' => 'file/embed_upload'
);
-
+
return $value;
}
-
-
+
+
/**
* Populates the ->getUrl() method for file objects
*
@@ -293,13 +293,13 @@
function file_url($entity) {
$title = $entity->title;
$title = elgg_get_friendly_title($title);
- return "pg/file/" . $entity->getOwnerEntity()->username . "/read/" . $entity->getGUID() . "/" . $title;
+ return "pg/file/" . $entity->getOwnerEntity()->username . "/read/" . $entity->getGUID() . "/" . $title;
}
-
+
// Make sure test_init is called on initialisation
register_elgg_event_handler('init','system','file_init');
register_elgg_event_handler('pagesetup','system','file_submenus');
-
+
// Register actions
register_action("file/upload", false, $CONFIG->pluginspath . "file/actions/upload.php");
register_action("file/save", false, $CONFIG->pluginspath . "file/actions/save.php");
@@ -307,5 +307,5 @@
// temporary - see #2010
register_action("file/download", false, $CONFIG->pluginspath. "file/actions/download.php");
-
+
?>
diff --git a/mod/file/views/default/object/file.php b/mod/file/views/default/object/file.php
index 5858a1f1e..3da9567a5 100644
--- a/mod/file/views/default/object/file.php
+++ b/mod/file/views/default/object/file.php
@@ -2,14 +2,14 @@
/**
* Elgg file browser.
* File renderer.
- *
+ *
* @package ElggFile
*/
global $CONFIG;
-
+
$file = $vars['entity'];
-
+
$file_guid = $file->getGUID();
$tags = $file->tags;
$title = $file->title;
@@ -17,13 +17,13 @@
$owner = $vars['entity']->getOwnerEntity();
$friendlytime = elgg_view_friendly_time($vars['entity']->time_created);
$mime = $file->mimetype;
-
+
if (!$title) {
$title = elgg_echo('untitled');
}
-
+
if (elgg_get_context() == "search") { // Start search listing version
-
+
if (get_input('search_viewtype') == "gallery") {
echo "<div class='filerepo_gallery_item'>";
if ($vars['entity']->smallthumb) {
@@ -34,25 +34,25 @@
//get the number of comments
$numcomments = elgg_count_comments($vars['entity']);
if ($numcomments)
- echo "<p class='filerepo_comments'><a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a></p>";
+ echo "<p class='filerepo_comments'><a href=\"{$file->getURL()}\">" . elgg_echo("comments") . " (" . $numcomments . ")</a></p>";
+
-
//if the user can edit, display edit and delete links
if ($file->canEdit()) {
echo "<div class='filerepo_controls'><p>";
echo "<a href=\"".elgg_get_site_url()."mod/file/edit.php?file_guid={$file->getGUID()}\">" . elgg_echo('edit') . "</a>&nbsp;";
echo elgg_view('output/confirmlink',array(
-
+
'href' => "action/file/delete?file=" . $file->getGUID(),
'text' => elgg_echo("delete"),
'confirm' => elgg_echo("file:delete:confirm"),
'is_action' => true,
-
+
));
echo "</p></div>";
}
-
-
+
+
} else {
echo "<p class='filerepo_title'>{$title}</p>";
echo "<a href=\"{$file->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid, 'size' => 'large')) . "</a>";
@@ -60,58 +60,58 @@
//get the number of comments
$numcomments = elgg_count_comments($file);
if ($numcomments)
- echo "<p class='filerepo_comments'><a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a></p>";
+ echo "<p class='filerepo_comments'><a href=\"{$file->getURL()}\">" . elgg_echo("comments") . " (" . $numcomments . ")</a></p>";
}
echo "</div>";
-
+
} else {
-
+
$info = "<p class='entity_title'> <a href=\"{$file->getURL()}\">{$title}</a></p>";
$info .= "<p class='entity_subtext'><a href=\"".elgg_get_site_url()."pg/file/{$owner->username}\">{$owner->name}</a> {$friendlytime}";
$numcomments = elgg_count_comments($file);
if ($numcomments)
- $info .= ", <a href=\"{$file->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>";
+ $info .= ", <a href=\"{$file->getURL()}\">" . elgg_echo("comments") . " (" . $numcomments . ")</a>";
$info .= "</p>";
$icon = "<a href=\"{$file->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid, 'size' => 'small')) . "</a>";
-
+
echo elgg_view_listing($icon, $info);
-
+
}
-
+
} else { // Start main version
-
+
?>
<div class="filerepo_file">
<div class="filerepo_icon">
- <a href="<?php echo elgg_get_site_url(); ?>mod/file/download.php?file_guid=<?php echo $file_guid; ?>"><?php
-
- echo elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid));
-
- ?></a>
+ <a href="<?php echo elgg_get_site_url(); ?>mod/file/download.php?file_guid=<?php echo $file_guid; ?>"><?php
+
+ echo elgg_view("file/icon", array("mimetype" => $mime, 'thumbnail' => $file->thumbnail, 'file_guid' => $file_guid));
+
+ ?></a>
</div>
-
+
<div class="filerepo_title_owner_wrapper">
<?php
//get the user and a link to their gallery
$user_gallery = elgg_get_site_url() . "mod/file/search.php?md_type=simpletype&subtype=file&tag=image&owner_guid=" . $owner->guid . "&search_viewtype=gallery";
?>
- <div class="filerepo_user_gallery_link"><a href="<?php echo $user_gallery; ?>"><?php echo sprintf(elgg_echo("file:user:gallery"),''); ?></a></div>
+ <div class="filerepo_user_gallery_link"><a href="<?php echo $user_gallery; ?>"><?php echo elgg_echo("file:user:gallery",array('')); ?></a></div>
<div class="filerepo_title"><h2><a href="<?php echo elgg_get_site_url(); ?>mod/file/download.php?file_guid=<?php echo $file_guid; ?>"><?php echo $title; ?></a></h2></div>
<div class="filerepo_owner">
<?php
echo elgg_view("profile/icon",array('entity' => $owner, 'size' => 'tiny'));
-
+
?>
<p class="filerepo_owner_details"><b><a href="<?php echo elgg_get_site_url(); ?>pg/file/<?php echo $owner->username; ?>"><?php echo $owner->name; ?></a></b><br />
<small><?php echo $friendlytime; ?></small></p>
</div>
</div>
-
+
<div class="filerepo_maincontent">
-
+
<div class="filerepo_description"><?php echo elgg_view('output/longtext', array('value' => $desc)); ?></div>
<?php
@@ -129,17 +129,17 @@
}
?>
- <?php
+ <?php
if (elgg_view_exists('file/specialcontent/' . $mime)) {
echo "<div class='filerepo_specialcontent'>".elgg_view('file/specialcontent/' . $mime, $vars)."</div>";
} else if (elgg_view_exists("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default")) {
echo "<div class='filerepo_specialcontent'>".elgg_view("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default", $vars)."</div>";
}
-
+
?>
-
+
<div class="filerepo_download"><p><a class="action_button small" href="<?php echo elgg_get_site_url(); ?>mod/file/download.php?file_guid=<?php echo $file_guid; ?>"><?php echo elgg_echo("file:download"); ?></a></p></div>
-
+
<?php
if ($file->canEdit()) {
@@ -147,21 +147,21 @@
<div class="filerepo_controls">
<p>
- <a href="<?php echo elgg_get_site_url(); ?>mod/file/edit.php?file_guid=<?php echo $file->getGUID(); ?>"><?php echo elgg_echo('edit'); ?></a>&nbsp;
- <?php
+ <a href="<?php echo elgg_get_site_url(); ?>mod/file/edit.php?file_guid=<?php echo $file->getGUID(); ?>"><?php echo elgg_echo('edit'); ?></a>&nbsp;
+ <?php
echo elgg_view('output/confirmlink',array(
-
+
'href' => "action/file/delete?file=" . $file->getGUID(),
'text' => elgg_echo("delete"),
'confirm' => elgg_echo("file:delete:confirm"),
'is_action' => true,
-
- ));
+
+ ));
?>
</p>
</div>
-<?php
+<?php
}
?>
@@ -171,9 +171,9 @@
<?php
if ($vars['full']) {
-
+
echo elgg_view_comments($file);
-
+
}
?>
diff --git a/mod/file/views/default/river/object/file/create.php b/mod/file/views/default/river/object/file/create.php
index b0e2ca07b..b9b5c4299 100644
--- a/mod/file/views/default/river/object/file/create.php
+++ b/mod/file/views/default/river/object/file/create.php
@@ -4,14 +4,14 @@
$object = get_entity($vars['item']->object_guid);
$url = $object->getURL();
$container = get_entity($object->container_guid);
-
+
$url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>";
- $string = sprintf(elgg_echo("file:river:created"),$url) . " " . elgg_echo("file:river:item");
+ $string = elgg_echo("file:river:created", array($url)) . " " . elgg_echo("file:river:item");
$string .= " <a href=\"" . $object->getURL() . "\">" . $object->title . "</a>";
if ($container && $container instanceof ElggGroup) {
$string .= ' ' . elgg_echo('groups:river:togroup') . " <a href=\"" . $container->getURL() ."\">". $container->name . "</a>";
}
echo $string;
-
+
?> \ No newline at end of file