Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1375888
clipboard_helper.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 1, 1:28 PM
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Feb 3, 1:28 PM (3 h, 11 m)
Engine
blob
Format
Raw Data
Handle
884519
Attached To
rINP In-Portal
clipboard_helper.php
View Options
<?php
class
kClipboardHelper
extends
kHelper
{
/**
* Set's clipboard mode
*
* @param kEvent $event
* @param string $mode
*/
function
setClipboard
(&
$event
,
$mode
,
$ids
)
{
// clipboard = { prefix1 = { cut = {idsA}, copy = {idsB} }, ... prefixN = { cut = {idsC}, copy = {idsD} } }
$object
=
$event
->
getObject
();
$clipboard
=
$this
->
Application
->
RecallVar
(
'clipboard'
);
$clipboard
=
$clipboard
?
unserialize
(
$clipboard
)
:
Array
();
$prefix
=
$event
->
getPrefixSpecial
();
// 1. add $ids to mode key for prefix (make sure the unique)
$this_mode_ids
=&
$clipboard
[
$prefix
][
$mode
];
if
(!
is_array
(
$this_mode_ids
))
{
$this_mode_ids
=
$ids
;
}
else
{
$this_mode_ids
=
array_unique
(
array_merge
(
$this_mode_ids
,
$ids
)
);
}
// 2. remove that ids from all other modes
$other_mode_ids
=&
$clipboard
[
$prefix
][
$mode
==
'cut'
?
'copy'
:
'cut'
];
if
(!
is_array
(
$other_mode_ids
))
{
$other_mode_ids
=
Array
();
}
else
{
$other_mode_ids
=
array_diff
(
$other_mode_ids
,
$this_mode_ids
);
}
$this
->
Application
->
StoreVar
(
'clipboard'
,
serialize
(
$clipboard
));
/*// do not go up - STAY
$event->SetRedirectParam('opener', 's');
$event->SetRedirectParam('pass_events', true);*/
}
}
?>
Event Timeline
Log In to Comment