New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepare Endpoint for Checkins #1248
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ function post() | |
|
||
// Get details | ||
$type = $this->getInput('h', 'entry'); | ||
$type = $this->getInput('h'); | ||
$content = $this->getInput('content'); | ||
$name = $this->getInput('name'); | ||
$in_reply_to = $this->getInput('in-reply-to'); | ||
|
@@ -80,6 +81,10 @@ function post() | |
$like_of = $this->getInput('like-of'); | ||
$repost_of = $this->getInput('repost-of'); | ||
$categories = $this->getInput('category'); | ||
$mp_type = $this->getInput('mp-type'); | ||
if (!empty($mp_type)) { | ||
$type = $mp_type; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: please use spaces for indentation (4-space indent) |
||
|
||
if ($type == 'entry') { | ||
$type = 'note'; | ||
|
@@ -99,6 +104,16 @@ function post() | |
$type = 'article'; | ||
} | ||
|
||
if ($type == 'checkin' ) { | ||
$place_name = $this->getInput('place_name'); | ||
$location = $this->getInput('location'); | ||
$type = 'checkin'; | ||
$latlong = explode(",",$location); | ||
$lat = str_ireplace("geo:", "", $latlong[0]); | ||
$long = $latlong[1]; | ||
$q = \IdnoPlugins\Checkin\Checkin::queryLatLong($lat, $long); | ||
$user_address = $q['display_name']; | ||
} | ||
if ($type == 'photo' && empty($name) && !empty($content)) { | ||
$name = $content; | ||
$content = ''; | ||
|
@@ -117,6 +132,24 @@ function post() | |
$category = trim($category); | ||
if ($category) { | ||
$content .= " #$category"; | ||
$categories = $this->getInput('category'); | ||
$location = $this->getInput('location'); | ||
|
||
if ($type == 'entry') { | ||
$type = 'article'; | ||
if (!empty($_FILES['photo'])) { | ||
$type = 'photo'; | ||
} else { | ||
$photo_url = $this->getInput('photo'); | ||
if ($photo_url) { | ||
$type = 'photo'; | ||
$success = $this->uploadFromUrl($photo_url); | ||
if (!$success) { | ||
\Idno\Core\Idno::site()->triggerEvent('indiepub/post/failure', ['page' => $this]); | ||
$this->setResponse(500); | ||
echo "Failed uploading photo from $photo_url"; | ||
exit; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this block seems to have migrated down from above (starting around line 81 in the old file)? maybe git made a mistake merging? |
||
} | ||
} | ||
$title_words = explode(" ", $name); | ||
|
@@ -128,6 +161,48 @@ function post() | |
} | ||
} | ||
|
||
// Get an appropriate plugin, given the content type | ||
if ($contentType = ContentType::getRegisteredForIndieWebPostType($type)) { | ||
if ($type == 'photo' && empty($name) && !empty($content)) { | ||
$name = $content; | ||
$content = ''; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm a little confused what happened here; this partially duplicates code from line ~102 |
||
|
||
if (empty($name)) { | ||
$type = 'note'; | ||
} | ||
if (!empty($location) ) { | ||
$place_name = $this->getInput('place_name'); | ||
$type = 'checkin'; | ||
$latlong = explode(",",$location); | ||
$lat = str_ireplace("geo:", "", $latlong[0]); | ||
$long = $latlong[1]; | ||
$q = \IdnoPlugins\Checkin\Checkin::queryLatLong($lat, $long); | ||
$user_address = $q['display_name']; | ||
} | ||
if (!empty($like_of)) { | ||
$type = 'like'; | ||
} | ||
if (!empty($repost_of)) { | ||
$type = 'repost'; | ||
} | ||
} | ||
$getInput = array($type, $content, $name, $in_reply_to, $syndicate, $posse_link, $like_of, $repost_of, $categories, $location); | ||
// setting all categories as hashtags into content field | ||
if (is_array($categories)) { | ||
foreach ($categories as $category) { | ||
$content .= " #$category"; | ||
} | ||
$title_words = explode(" ", $name); | ||
$name = ""; | ||
foreach ($title_words as $word) { | ||
if (substr($word,0,1) !== "#") { | ||
$name .= "$word "; | ||
} | ||
} | ||
} | ||
|
||
|
||
// Get an appropriate plugin, given the content type | ||
if ($contentType = ContentType::getRegisteredForIndieWebPostType($type)) { | ||
if ($entity = $contentType->createEntity()) { | ||
|
@@ -151,6 +226,13 @@ function post() | |
$this->setInput('like-of', $like_of); | ||
$this->setInput('repost-of', $repost_of); | ||
$this->setInput('access', 'PUBLIC'); | ||
$this->setInput('lat', $lat); | ||
$this->setInput('long', $long); | ||
$this->setInput('user_address', ""); | ||
$this->setInput('placename',$place_name); | ||
$this->setInput('long', $long); | ||
$this->setInput('user_address', ""); | ||
$this->setInput('placename',$place_name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: you've got these three lines twice. |
||
if ($created = $this->getInput('published')) { | ||
$this->setInput('created', $created); | ||
} | ||
|
@@ -160,7 +242,6 @@ function post() | |
} else { | ||
$syndication = array(trim(str_replace('.com', '', $syndicate))); | ||
} | ||
\Idno\Core\Idno::site()->logging()->log("Setting syndication: $syndication"); | ||
$this->setInput('syndication', $syndication); | ||
} | ||
if ($entity->saveDataFromInput($this)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line repeats the previous one.