From cc23bbddb8f2367f33e6291b13354c4cd98cd97b Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 22 Sep 2011 21:55:25 -0400 Subject: Fixes #3795 not inserting the file title when embeding a file and tweaked css - thanks to slyhne --- mod/file/views/default/embed/file/content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/file/views/default/embed') diff --git a/mod/file/views/default/embed/file/content.php b/mod/file/views/default/embed/file/content.php index 865a158a7..eadcd1a6d 100644 --- a/mod/file/views/default/embed/file/content.php +++ b/mod/file/views/default/embed/file/content.php @@ -31,7 +31,7 @@ if ($count) { $subtitle = "$author_text $date"; - $icon = "getIconURL($icon_size)}\" />" . htmlentities($title, ENT_QUOTES, 'UTF-8'); + $icon = "getIconURL($icon_size)}\" />"; $embed_code = elgg_view('output/url', array( 'href' => $item->getURL(), -- cgit v1.2.3 From bc292c96ac6b118bd7a99509fce1c11bb232aeb2 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 1 Oct 2011 16:54:24 -0400 Subject: fixed the forwarding of an embed upload form --- mod/embed/views/default/js/embed/embed.php | 5 +- mod/file/views/default/embed/file/content.php | 61 ---------------------- .../views/default/embed/file_upload/content.php | 9 +++- 3 files changed, 9 insertions(+), 66 deletions(-) delete mode 100644 mod/file/views/default/embed/file/content.php (limited to 'mod/file/views/default/embed') diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index 37246ee8a..6d4e2e4ea 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -79,9 +79,8 @@ elgg.embed.submit = function(event) { elgg.system_message(response.system_messages.success); } if (response.status >= 0) { - // @todo - really this should forward to what the registered defined - // For example, forward to images tab if an image was uploaded - var url = elgg.config.wwwroot + 'embed/embed'; + var forward = $('input[name=embed_forward]').val(); + var url = elgg.normalize_url('embed/tab/' + forward); $('.embed-wrapper').parent().load(url); } } diff --git a/mod/file/views/default/embed/file/content.php b/mod/file/views/default/embed/file/content.php deleted file mode 100644 index eadcd1a6d..000000000 --- a/mod/file/views/default/embed/file/content.php +++ /dev/null @@ -1,61 +0,0 @@ - elgg_get_logged_in_user_guid(), - 'type_subtype_pair' => array('object' => 'file'), - 'count' => true -); - -$count = elgg_get_entities($options); - -if ($count) { - echo "
"; - - 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 = "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 "
getGUID()}\">" . elgg_view_image_block($item_icon, $list_body) . '
'; - echo ""; - } - - echo '
'; -} \ 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 index 13c18f745..a530b3194 100644 --- a/mod/file/views/default/embed/file_upload/content.php +++ b/mod/file/views/default/embed/file_upload/content.php @@ -9,7 +9,12 @@ $form_vars = array( ); $upload_content = elgg_view_form('file/upload', $form_vars); -echo "
" . elgg_echo('embed:upload_type') . "$input
"; echo "
"; echo $upload_content; -echo "
"; \ No newline at end of file +echo ""; + +// the tab we want to be forwarded to after upload is complete +echo elgg_view('input/hidden', array( + 'name' => 'embed_forward', + 'value' => 'file', +)); \ No newline at end of file -- cgit v1.2.3 From fa04d6615760a014f7557f2d28ff864eebce8551 Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 3 Oct 2011 21:30:30 -0400 Subject: removed the sections from the menu to provide more flexibility in tab ordering --- mod/embed/README.txt | 36 ++++++++++++---------- mod/embed/views/default/embed/css.php | 2 +- mod/embed/views/default/embed/layout.php | 25 +++++++-------- mod/embed/views/default/js/embed/embed.php | 2 +- mod/embed/views/default/navigation/menu/embed.php | 19 +++++------- mod/file/start.php | 6 ++-- .../views/default/embed/file_upload/content.php | 8 ++--- 7 files changed, 44 insertions(+), 54 deletions(-) (limited to 'mod/file/views/default/embed') diff --git a/mod/embed/README.txt b/mod/embed/README.txt index c7ce2e528..cecee08c0 100644 --- a/mod/embed/README.txt +++ b/mod/embed/README.txt @@ -13,8 +13,9 @@ CONTENTS: their personal network content or third party resources in any text area. The Embed plugin adds a menu item to the longtext menu. Clicking on this - link pops up a lightbox. The lightbox has two types of tabs: one for - selecting content to embed and one for uploading new content. + link pops up a lightbox. The lightbox supports lists of content for insertion + and uploading new content. + 2. Adding a Tab The Embed plugin uses the menu system to manage its tabs. Use @@ -23,7 +24,7 @@ CONTENTS: $item = ElggMenuItem::factory(array( 'name' => 'file', 'text' => elgg_echo('file'), - 'section' => 'select', + 'priority' => 10, 'data' => array( 'options' => array( 'type' => 'object', @@ -36,32 +37,33 @@ CONTENTS: Parameters: name: The unique name of the tab. text: The text shown on the tab - section: 'select' for embed selection or 'upload' for uploading new content - data: an array of parameters for creating the tab and its content. See - the two sections below for data key values for the two tab types. - - Select tab data parameters: - options: array of options passed to elgg_list_entities() - - Upload tab data parameters: - view: the view used to render the tab content + priority: Placement of the tab. + data: An array of parameters for creating the tab and its content. + When listing content using the embed list view, pass the options for the + elgg_list_entities() function as 'options'. + When using a custom view for listing content or for uploading new + content, pass the view name as 'view'. See the file plugin for examples of registering both tab types. -3. Populating a Select Tab +3. Populating a Content Select Tab Nothing should be required other than setting the options parameter array when registering the tab. See the view embed/item to see how an entity is rendered. + If creating a custom list, the
  • elements must have a class of .embed-item. + The HTML content that is inserted must use the class .elgg-image. + + 4. Populating an Upload Tab The view that is registered must be defined. It must include a form for - uploading the content. The form must be wrapped in a div with the class - .embed-upload. Somewhere in the view must be a hidden input field with the - name embed_hidden with its value be the name of the tab to forward the user - to when uploading is complete. + uploading the content. The form must .elgg-form-embed. Somewhere in the view + must be a hidden input field with the name embed_hidden with its value be + the name of the tab to forward the user to when uploading is complete. See the view embed/file_upload/content for an example + 5. Other WYSIWYG Editors and Embed Embed ships with support for the default input/longtext textarea. diff --git a/mod/embed/views/default/embed/css.php b/mod/embed/views/default/embed/css.php index 324ed1038..034c0fcfe 100644 --- a/mod/embed/views/default/embed/css.php +++ b/mod/embed/views/default/embed/css.php @@ -8,7 +8,7 @@ .embed-wrapper { width: 730px; min-height: 400px; - margin: 15px; + margin: 20px 15px; } .embed-wrapper h2 { color: #333333; diff --git a/mod/embed/views/default/embed/layout.php b/mod/embed/views/default/embed/layout.php index 73c26810d..c1e43f13c 100644 --- a/mod/embed/views/default/embed/layout.php +++ b/mod/embed/views/default/embed/layout.php @@ -8,20 +8,17 @@ $title = elgg_view_title(elgg_echo('embed:media')); $menu = elgg_view_menu('embed'); $selected = elgg_get_config('embed_tab'); -switch ($selected->getData('tab_type')) { - case 'select': - $tab = elgg_list_entities( - embed_get_list_options($selected->getData('options')), - 'elgg_get_entities', - 'embed_list_items' - ); - if (!$tab) { - $tab = elgg_echo('embed:no_section_content'); - } - break; - case 'upload': - $tab = elgg_view($selected->getData('view'), $vars); - break; +if ($selected->getData('view')) { + $tab = elgg_view($selected->getData('view'), $vars); +} else { + $tab = elgg_list_entities( + embed_get_list_options($selected->getData('options')), + 'elgg_get_entities', + 'embed_list_items' + ); + if (!$tab) { + $tab = elgg_echo('embed:no_section_content'); + } } echo << $menu_item->getText(), - 'url' => 'embed/tab/' . $menu_item->getName(), - 'url_class' => 'embed-section', - 'selected' => $menu_item->getSelected(), - ); - } +foreach ($vars['menu']['default'] as $menu_item) { + $tabs[] = array( + 'title' => $menu_item->getText(), + 'url' => 'embed/tab/' . $menu_item->getName(), + 'url_class' => 'embed-section', + 'selected' => $menu_item->getSelected(), + ); } echo elgg_view('navigation/tabs', array('tabs' => $tabs)); diff --git a/mod/file/start.php b/mod/file/start.php index 16ce0e233..843ae0794 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -61,9 +61,8 @@ function file_init() { $item = ElggMenuItem::factory(array( 'name' => 'file', 'text' => elgg_echo('file'), - 'section' => 'select', + 'priority' => 10, 'data' => array( - 'tab_type' => 'select', 'options' => array( 'type' => 'object', 'subtype' => 'file', @@ -75,9 +74,8 @@ function file_init() { $item = ElggMenuItem::factory(array( 'name' => 'file_upload', 'text' => elgg_echo('file:upload'), - 'section' => 'upload', + 'priority' => 100, 'data' => array( - 'tab_type' => 'upload', 'view' => 'embed/file_upload/content', ), )); diff --git a/mod/file/views/default/embed/file_upload/content.php b/mod/file/views/default/embed/file_upload/content.php index a530b3194..4d3db0d97 100644 --- a/mod/file/views/default/embed/file_upload/content.php +++ b/mod/file/views/default/embed/file_upload/content.php @@ -5,13 +5,9 @@ $form_vars = array( 'enctype' => 'multipart/form-data', - 'class' => 'elgg-form', + 'class' => 'elgg-form-embed', ); -$upload_content = elgg_view_form('file/upload', $form_vars); - -echo "
    "; -echo $upload_content; -echo "
    "; +echo elgg_view_form('file/upload', $form_vars); // the tab we want to be forwarded to after upload is complete echo elgg_view('input/hidden', array( -- cgit v1.2.3