Skip to content

Commit 1e7432f

Browse files
committed
Adjusted existing attachments tab UI
1 parent 5e1d5f5 commit 1e7432f

13 files changed

Lines changed: 146 additions & 59 deletions

htsrv/async.php

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,10 @@
11931193
$links = array();
11941194
$link_owner_class = get_class( $LinkOwner->link_Object );
11951195

1196+
load_class( '_core/model/dataobjects/_dataobjectlist2.class.php', 'DataObjectList2' );
1197+
$LinkCache = & get_LinkCache();
1198+
$ea_Linklist = new DataObjectList2( $LinkCache );
1199+
11961200
switch( $link_owner_class )
11971201
{
11981202
case 'Item':
@@ -1214,20 +1218,15 @@
12141218
$comments_SQL->WHERE( 'comment_item_ID = '.$DB->quote( $item_ID ) );
12151219
$comment_IDs = $DB->get_col( $comments_SQL );
12161220

1217-
load_class( '_core/model/dataobjects/_dataobjectlist2.class.php', 'DataObjectList2' );
1218-
$LinkCache = & get_LinkCache();
1219-
$ea_Linklist = new DataObjectList2( $LinkCache );
1220-
12211221
$links_SQL = new SQL( 'Get all the links belonging to comments of an Item' );
1222-
$links_SQL->SELECT( 'l.*' );
1222+
$links_SQL->SELECT( '*' );
12231223
$links_SQL->FROM( 'T_links AS l' );
1224-
$links_SQL->FROM_add( 'LEFT JOIN T_comments AS c ON c.comment_ID = l.link_cmt_ID' );
12251224
if( $comment_IDs )
12261225
{
12271226
$links_SQL->WHERE( 'link_cmt_ID IN ('.$DB->quote( $comment_IDs ).')' );
12281227
}
12291228
$links_SQL->WHERE_or( 'link_itm_ID = '.$DB->quote( $item_ID ) );
1230-
$links_SQL->ORDER_BY( 'c.comment_date DESC' );
1229+
$links_SQL->ORDER_BY( 'link_datemodified DESC, link_datecreated DESC' );
12311230

12321231
$ea_Linklist->sql = $links_SQL->get();
12331232
$ea_Linklist->run_query( false, false, false, 'get_attachment_LinkList' );
@@ -1257,6 +1256,45 @@
12571256
$selected_Filelist = new Filelist( $fm_FileRoot, false ); // Arbitrary list of attached files
12581257
break;
12591258

1259+
case 'EmailCampaign':
1260+
if( $edited_Newsletter = & $LinkOwner->link_Object->get_Newsletter() )
1261+
{
1262+
// Get list of email campaign IDs under the same Newsletter:
1263+
$email_campaigns_SQL = new SQL( 'Get all the email campaigns of a List' );
1264+
$email_campaigns_SQL->SELECT( 'ecmp_ID' );
1265+
$email_campaigns_SQL->FROM( 'T_email__campaign' );
1266+
$email_campaigns_SQL->WHERE( 'ecmp_enlt_ID = '.$DB->quote( $edited_Newsletter->ID ) );
1267+
$email_campaign_IDs = $DB->get_col( $email_campaigns_SQL );
1268+
1269+
if( $email_campaign_IDs )
1270+
{
1271+
$links_SQL = new SQL( 'Get all the links belonging to email campaigns of a List' );
1272+
$links_SQL->SELECT( '*' );
1273+
$links_SQL->FROM( 'T_links AS l' );
1274+
$links_SQL->WHERE( 'link_ecmp_ID IN ('.$DB->quote( $email_campaign_IDs ).')' );
1275+
$links_SQL->ORDER_BY( 'link_datemodified DESC, link_datecreated DESC' );
1276+
1277+
$ea_Linklist->sql = $links_SQL->get();
1278+
$ea_Linklist->run_query( false, false, false, 'get_attachment_LinkList' );
1279+
}
1280+
}
1281+
1282+
// Get FileRoot and dummy FileList:
1283+
if( $ea_Linklist->get_total_rows() )
1284+
{ // Use first attachment to get the FileRoot:
1285+
$Link = & $ea_Linklist->get_by_idx( 0 );
1286+
$File = & $Link->get_File();
1287+
$fm_FileRoot = & $File->get_FileRoot();
1288+
}
1289+
else
1290+
{
1291+
$fm_FileRoot = & $FileRootCache->get_by_type_and_ID( 'emailcampaign', $LinkOwner->link_Object->ID );
1292+
}
1293+
load_class( 'files/model/_filelist.class.php', 'FileList' );
1294+
$fm_Filelist = new Filelist( $fm_FileRoot, false ); // Arbitrary list of attached files
1295+
$selected_Filelist = new Filelist( $fm_FileRoot, false ); // Arbitrary list of attached files
1296+
break;
1297+
12601298
default:
12611299
debug_die( 'Existing attachments list not available to '.$link_owner_class );
12621300
}
@@ -1268,7 +1306,6 @@
12681306

12691307
$AdminUI = new AdminUI();
12701308
$Widget = new Widget( 'file_browser' );
1271-
$Widget->title = T_('Existing attachments').get_manual_link('existing-attachments');
12721309
$Widget->disp_template_replaced( 'block_start' );
12731310

12741311
require $inc_path.'links/views/_link_file_list.inc.php';

inc/email_campaigns/model/_emailcampaign.class.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,20 @@ function add_user_to_automation( $click_type, $user_ID )
17331733

17341734
return empty( $added_users_num ) ? false : $added_users_num;
17351735
}
1736+
1737+
1738+
/**
1739+
* Get creation time of Email Campaign
1740+
*
1741+
* @param string date/time format: leave empty to use locale default date format
1742+
* @param boolean true if you want GMT
1743+
*/
1744+
function get_creation_time( $format = '', $useGM = false )
1745+
{
1746+
$format = locale_resolve_datetime_fmt( $format );
1747+
1748+
return mysql2date( $format, $this->date_ts, $useGM );
1749+
}
17361750
}
17371751

1738-
?>
1752+
?>

inc/files/files.ctrl.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,24 +1842,27 @@
18421842
// -------------------
18431843
// Browsing interface:
18441844
// -------------------
1845-
if( ( $mode == 'upload' ) && in_array( get_class( $LinkOwner->link_Object ), array( 'Comment', 'Item' ) ) )
1845+
$show_existing_attachments_tab = ( $mode == 'upload' ) && isset( $LinkOwner ) && in_array( get_class( $LinkOwner->link_Object ), array( 'Comment', 'Item', 'EmailCampaign' ) );
1846+
if( $show_existing_attachments_tab )
18461847
{ // Display existing attachments tab:
18471848
$attach_files_url = get_htsrv_url().'async.php?action=browse_existing_attachments&root='.$root
18481849
.'&path='.$path
18491850
.'&prefix='.$prefix
18501851
.'&link_type='.( $LinkOwner->is_temp() ? 'temporary' : $LinkOwner->type )
18511852
.( $LinkOwner->type != 'message' ? '&link_object_ID='.$LinkOwner->get_ID() : '' );
18521853
?>
1853-
<ul class="nav nav-tabs">
1854-
<li class="active">
1855-
<a href="#file_browser" data-toggle="tab"><?php echo T_('File browser'); ?></a>
1856-
</li>
1857-
<li>
1858-
<a href="<?php echo $attach_files_url;?>" data-toggle="tabajax" data-target="#existing_attachments">
1859-
<?php echo T_('Existing attachments'); ?>
1860-
</a>
1861-
</li>
1862-
</ul>
1854+
<div class="margin-bottom-md">
1855+
<ul class="nav nav-tabs">
1856+
<li class="active">
1857+
<a href="#file_browser" data-toggle="tab"><?php echo T_('File browser'); ?></a>
1858+
</li>
1859+
<li>
1860+
<a href="<?php echo $attach_files_url;?>" data-toggle="tabajax" data-target="#existing_attachments">
1861+
<?php echo T_('Existing attachments'); ?>
1862+
</a>
1863+
</li>
1864+
</ul>
1865+
</div>
18631866
<div class="tab-content">
18641867
<div class="tab-pane active" id="file_browser">
18651868
<?php

inc/files/model/_file.funcs.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3195,7 +3195,7 @@ function file_td_name( & $File )
31953195
* @param object File
31963196
* @return string
31973197
*/
3198-
function file_td_actions( & $File )
3198+
function file_td_actions( & $File, $except = array() )
31993199
{
32003200
global $admin_url;
32013201

@@ -3224,11 +3224,23 @@ function file_td_actions( & $File )
32243224

32253225
if( $File->can_be_manipulated() )
32263226
{
3227-
$r .= action_icon( T_('Edit properties...'), 'properties', $action_crumb_url.'action=edit_properties', NULL, NULL, NULL,
3228-
array( 'onclick' => 'return file_properties( \''.get_param( 'root' ).'\', \''.get_param( 'path' ).'\', \''.$File->get_rdfp_rel_path().'\' )' ) );
3229-
$r .= action_icon( T_('Move'), 'file_move', $action_url.'action=file_move&amp;fm_sources_root='.$FileRoot->ID );
3230-
$r .= action_icon( T_('Copy'), 'file_copy', $action_url.'action=file_copy&amp;fm_sources_root='.$FileRoot->ID );
3231-
$r .= action_icon( T_('Delete'), 'file_delete', $action_crumb_url.'action=delete' );
3227+
if( !in_array( 'edit', $except ) )
3228+
{
3229+
$r .= action_icon( T_('Edit properties...'), 'properties', $action_crumb_url.'action=edit_properties', NULL, NULL, NULL,
3230+
array( 'onclick' => 'return file_properties( \''.$FileRoot->ID.'\', \''.$File->get_dir_rel_path().'\', \''.$File->get_rdfp_rel_path().'\' )' ) );
3231+
}
3232+
if( !in_array( 'move', $except ) )
3233+
{
3234+
$r .= action_icon( T_('Move'), 'file_move', $action_url.'action=file_move&amp;fm_sources_root='.$FileRoot->ID );
3235+
}
3236+
if( !in_array( 'copy', $except ) )
3237+
{
3238+
$r .= action_icon( T_('Copy'), 'file_copy', $action_url.'action=file_copy&amp;fm_sources_root='.$FileRoot->ID );
3239+
}
3240+
if( !in_array( 'delete', $except ) )
3241+
{
3242+
$r .= action_icon( T_('Delete'), 'file_delete', $action_crumb_url.'action=delete' );
3243+
}
32323244
}
32333245

32343246
return $r;

inc/files/views/_file_browse.view.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242

4343
global $blog;
4444

45+
global $show_existing_attachments_tab;
46+
4547
if( isset( $edited_User ) )
4648
{ // Display a help notice for setting a new avatar:
4749
printf( '<div>'.T_( 'Click on a link %s icon below to select the image to use as your profile picture.' )
@@ -56,7 +58,7 @@
5658

5759
$close_link_params = array();
5860
if( $ajax_request )
59-
{ // Initialize JavaScript functions to work with modal window:
61+
{ // Initialize JavaScript functions to work with modal window:
6062
echo_modalwindow_js();
6163
$close_link_params['onclick'] = 'return closeModalWindow( window.parent.document )';
6264
}
@@ -66,26 +68,29 @@
6668
if( ! isset( $AdminUI->skin_name ) || $AdminUI->skin_name != 'bootstrap' )
6769
{ // Don't display a close icon, because it is already displayed on bootstrap modal window header:
6870
if( ! empty( $LinkOwner ) )
69-
{ // Get an url to return to owner(post/comment) editing
71+
{ // Get an url to return to owner(post/comment) editing
7072
$icon_close_url = $LinkOwner->get_edit_url();
7173
}
7274
elseif( $mode == 'import' )
73-
{ // Get an url to return to WordPress Import page
75+
{ // Get an url to return to WordPress Import page
7476
global $admin_url;
7577
$icon_close_url = $admin_url.'?ctrl=wpimportxml';
7678
}
7779
else
78-
{ // Unknown case, leave empty url
80+
{ // Unknown case, leave empty url
7981
$icon_close_url = '';
8082
}
8183

8284
if( ! empty( $icon_close_url ) || ! empty( $close_link_params ) )
83-
{ // Display a link to close file browser
85+
{ // Display a link to close file browser
8486
$Widget->global_icon( T_('Close file manager'), 'close', $icon_close_url, '', 3, 2, $close_link_params );
8587
}
8688
}
8789

88-
$Widget->title = T_('File browser').get_manual_link('file-browser');
90+
if( empty( $show_existing_attachments_tab ) )
91+
{
92+
$Widget->title = T_('File browser').get_manual_link('file-browser');
93+
}
8994
$Widget->disp_template_replaced( 'block_start' );
9095
?>
9196

@@ -406,4 +411,4 @@ function( data )
406411
return false;
407412
} );
408413
} );
409-
</script>
414+
</script>

inc/links/views/_link_file_list.inc.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
echo '<th class="nowrap">'./* TRANS: file group */ T_('Group').'</th>';
128128
}
129129

130+
echo '<th class="lastcol nowrap">'. /* TRANS: file actions; edit, rename, copy, .. */ T_('Actions').'</th>';
130131
echo '</tr>';
131132
?>
132133
</thead>
@@ -287,6 +288,7 @@
287288
{
288289
case 'Comment':
289290
case 'Item':
291+
case 'EmailCampaign':
290292
$owner_date = $lLinkOwner->link_Object->get_creation_time();
291293
break;
292294
}
@@ -339,16 +341,26 @@
339341
evo_flush();
340342
}
341343

344+
/***************** Action icons ****************/
345+
346+
echo '<td class="actions lastcol text-nowrap">';
347+
echo file_td_actions( $lFile, array( 'move', 'copy', 'delete' ) );
348+
echo '</td>';
349+
evo_flush();
350+
351+
echo '</tr>';
352+
evo_flush();
353+
342354

343355
$countFiles++;
344356
}
345357
// End of file list..
346358

347359

348360
/**
349-
* @global integer Number of cols for the files table, 4 is minimum.
361+
* @global integer Number of cols for the files table, 5 is minimum.
350362
*/
351-
$filetable_cols = 4
363+
$filetable_cols = 5
352364
+ ( int ) $fm_flatmode
353365
+ ( int ) $UserSettings->get( 'fm_showcreator' )
354366
+ ( int ) $UserSettings->get( 'fm_showtypes' )

rsc/build/bootstrap-b2evo_base-superbundle.bmin.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rsc/build/bootstrap-b2evo_base-superbundle.bundle.css

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14728,13 +14728,14 @@ div.message_toolbars {
1472814728
}
1472914729
#modal_window.evo_modal_window__percent_height .modal-content {
1473014730
height: 100%;
14731-
overflow: hidden;
14731+
display: flex;
14732+
flex-direction: column;
1473214733
}
1473314734
#modal_window.evo_modal_window__percent_height .modal-body {
14734-
height: 100%;
14735-
overflow: hidden;
14736-
padding-top: 0;
14737-
padding-bottom: 70px;
14735+
flex-grow: 1;
14736+
}
14737+
#modal_window.evo_modal_window__percent_height .modal-footer {
14738+
flex-shrink: 0;
1473814739
}
1473914740
.tt-dropdown-menu {
1474014741
background-color: #FFFFFF;

rsc/build/bootstrap-b2evo_base.bmin.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rsc/build/bootstrap-b2evo_base.bundle.css

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5578,13 +5578,14 @@ div.message_toolbars {
55785578
}
55795579
#modal_window.evo_modal_window__percent_height .modal-content {
55805580
height: 100%;
5581-
overflow: hidden;
5581+
display: flex;
5582+
flex-direction: column;
55825583
}
55835584
#modal_window.evo_modal_window__percent_height .modal-body {
5584-
height: 100%;
5585-
overflow: hidden;
5586-
padding-top: 0;
5587-
padding-bottom: 70px;
5585+
flex-grow: 1;
5586+
}
5587+
#modal_window.evo_modal_window__percent_height .modal-footer {
5588+
flex-shrink: 0;
55885589
}
55895590
.tt-dropdown-menu {
55905591
background-color: #FFFFFF;

0 commit comments

Comments
 (0)