Support both html-form and json syntax for mp-syndicate-to and photos
This commit is contained in:
parent
2c7abbad07
commit
42d55f88dc
1 changed files with 25 additions and 13 deletions
|
@ -97,8 +97,14 @@ class MicropubController extends Controller
|
|||
}
|
||||
$data['syndicate'] = [];
|
||||
$targets = array_pluck(config('syndication.targets'), 'uid', 'service.name');
|
||||
if (is_string($request->input('mp-syndicate-to'))) {
|
||||
$service = array_search($request->input('mp-syndicate-to'), $targets);
|
||||
if ($request->has('mp-syndicate-to')) {
|
||||
$mpSyndicateTo = $request->input('mp-syndicate-to');
|
||||
}
|
||||
if ($request->has('properties.mp-syndicate-to')) {
|
||||
$mpSyndicateTo = $request->input('properties.mp-syndicate-to');
|
||||
}
|
||||
if (is_string($mpSyndicateTo)) {
|
||||
$service = array_search($mpSyndicateTo, $targets);
|
||||
if ($service == 'Twitter') {
|
||||
$data['syndicate'][] = 'twitter';
|
||||
}
|
||||
|
@ -106,9 +112,9 @@ class MicropubController extends Controller
|
|||
$data['syndicate'][] = 'facebook';
|
||||
}
|
||||
}
|
||||
if (is_array($request->input('mp-syndicate-to'))) {
|
||||
foreach ($targets as $service => $target) {
|
||||
if (in_array($target, $request->input('mp-syndicate-to'))) {
|
||||
if (is_array($mpSyndicateTo)) {
|
||||
foreach ($mpSyndicateTo as $uid) {
|
||||
$service = array_search($uid, $targets);
|
||||
if ($service == 'Twitter') {
|
||||
$data['syndicate'][] = 'twitter';
|
||||
}
|
||||
|
@ -117,10 +123,16 @@ class MicropubController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['photo'] = [];
|
||||
if (is_array($request->input('photo'))) {
|
||||
foreach ($request->input('photo') as $photo) {
|
||||
$photos = null;
|
||||
if ($request->has('photo')) {
|
||||
$photos = $request->input('photo');
|
||||
}
|
||||
if ($request->has('properties.photo')) {
|
||||
$photos = $request->input('properties.photo');
|
||||
}
|
||||
if ($photos !== null) {
|
||||
foreach ($photos as $photo) {
|
||||
if (is_string($photo)) {
|
||||
//only supporting media URLs for now
|
||||
$data['photo'][] = $photo;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue