diff options
Diffstat (limited to 'mod/file')
-rw-r--r-- | mod/file/languages/en.php | 2 | ||||
-rw-r--r-- | mod/file/pages/file/search.php | 5 | ||||
-rw-r--r-- | mod/file/start.php | 87 | ||||
-rw-r--r-- | mod/file/views/default/embed/file/content.php | 61 | ||||
-rw-r--r-- | mod/file/views/default/embed/file_upload/content.php | 15 |
5 files changed, 100 insertions, 70 deletions
diff --git a/mod/file/languages/en.php b/mod/file/languages/en.php index 72b198d54..aa30084a9 100644 --- a/mod/file/languages/en.php +++ b/mod/file/languages/en.php @@ -75,6 +75,8 @@ $english = array( 'item:object:file' => 'Files', + 'file:newupload' => 'A new file has been uploaded', + /** * Embed media **/ diff --git a/mod/file/pages/file/search.php b/mod/file/pages/file/search.php index 3e85d45db..402a28933 100644 --- a/mod/file/pages/file/search.php +++ b/mod/file/pages/file/search.php @@ -6,6 +6,11 @@ */ $page_owner_guid = get_input('page_owner', null); + +if ($page_owner_guid !== null) { + $page_owner_guid = sanitise_int($page_owner_guid); +} + if ($page_owner_guid) { elgg_set_page_owner_guid($page_owner_guid); } diff --git a/mod/file/start.php b/mod/file/start.php index b94dc309a..749d7a519 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -57,11 +57,23 @@ function file_init() { // temporary - see #2010 elgg_register_action("file/download", "$action_path/download.php"); - // embed support - elgg_register_plugin_hook_handler('embed_get_sections', 'all', 'file_embed_get_sections'); - elgg_register_plugin_hook_handler('embed_get_items', 'file', 'file_embed_get_items'); - elgg_register_plugin_hook_handler('embed_get_upload_sections', 'all', 'file_embed_get_upload_sections'); + $item = ElggMenuItem::factory(array( + 'name' => 'file', + 'text' => elgg_echo('file'), + 'href' => '#', + 'section' => 'select' + )); + elgg_register_menu_item('embed:sections', $item); + + $item = ElggMenuItem::factory(array( + 'name' => 'file_upload', + 'text' => elgg_echo('file:upload'), + 'href' => '#', + 'section' => 'upload' + )); + + elgg_register_menu_item('embed:sections', $item); } /** @@ -332,69 +344,4 @@ function file_icon_url_override($hook, $type, $returnvalue, $params) { $url = elgg_trigger_plugin_hook('file:icon:url', 'override', $params, $url); return $url; } -} - -/** - * Register file as an embed type. - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ -function file_embed_get_sections($hook, $type, $value, $params) { - $value['file'] = array( - 'name' => elgg_echo('file'), - 'layout' => 'list', - 'icon_size' => 'small', - ); - - return $value; -} - -/** - * Return a list of files for embedding - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ -function file_embed_get_items($hook, $type, $value, $params) { - $options = array( - 'owner_guid' => elgg_get_logged_in_user_guid(), - '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. - * - * @param unknown_type $hook - * @param unknown_type $type - * @param unknown_type $value - * @param unknown_type $params - */ -function file_embed_get_upload_sections($hook, $type, $value, $params) { - $value['file'] = array( - 'name' => elgg_echo('file'), - 'view' => 'file/embed_upload' - ); - - return $value; -} +}
\ No newline at end of file diff --git a/mod/file/views/default/embed/file/content.php b/mod/file/views/default/embed/file/content.php new file mode 100644 index 000000000..eadcd1a6d --- /dev/null +++ b/mod/file/views/default/embed/file/content.php @@ -0,0 +1,61 @@ +<?php +/** + * List files available for upload + */ + +$active_section = elgg_extract('active_section', $vars); + +$options = array( + 'owner_guid' => elgg_get_logged_in_user_guid(), + 'type_subtype_pair' => array('object' => 'file'), + 'count' => true +); + +$count = elgg_get_entities($options); + +if ($count) { + echo "<div class='embed_modal_$active_section'>"; + + unset($options['count']); + $items = elgg_get_entities($options); + + foreach ($items as $item) { + + // different entity types have different title attribute names. + $title = isset($item->name) ? $item->name : $item->title; + // don't let it be too long + $title = elgg_get_excerpt($title); + + $author_text = elgg_echo('byline', array($owner->name)); + $date = elgg_view_friendly_time($item->time_created); + + $subtitle = "$author_text $date"; + + $icon = "<img src=\"{$item->getIconURL($icon_size)}\" />"; + + $embed_code = elgg_view('output/url', array( + 'href' => $item->getURL(), + 'title' => $title, + 'text' => $icon, + 'encode_text' => FALSE + )); + + $item_icon = elgg_view_entity_icon($item, $icon_size); + + $params = array( + 'title' => $title, + 'entity' => $item, + 'subtitle' => $subtitle, + 'tags' => FALSE, + ); + $list_body = elgg_view('object/elements/summary', $params); + + // @todo JS 1.8: is this approach better than inline js? + echo "<div class=\"embed_data\" id=\"embed_{$item->getGUID()}\">" . elgg_view_image_block($item_icon, $list_body) . '</div>'; + echo "<script type=\"text/javascript\"> + $('#embed_{$item->getGUID()}').data('embed_code', " . json_encode($embed_code) . "); + </script>"; + } + + echo '</div>'; +}
\ No newline at end of file diff --git a/mod/file/views/default/embed/file_upload/content.php b/mod/file/views/default/embed/file_upload/content.php new file mode 100644 index 000000000..13c18f745 --- /dev/null +++ b/mod/file/views/default/embed/file_upload/content.php @@ -0,0 +1,15 @@ +<?php +/** + * Upload a file through the embed interface + */ + +$form_vars = array( + 'enctype' => 'multipart/form-data', + 'class' => 'elgg-form', +); +$upload_content = elgg_view_form('file/upload', $form_vars); + +echo "<div class='mbm'>" . elgg_echo('embed:upload_type') . "$input</div>"; +echo "<div class='embed-upload'>"; +echo $upload_content; +echo "</div>";
\ No newline at end of file |