|
@@ -129,7 +129,6 @@ class StatusForm extends FormBase {
|
|
]
|
|
]
|
|
|
|
|
|
);
|
|
);
|
|
-$stophere = null;
|
|
|
|
return $form;
|
|
return $form;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -206,17 +205,13 @@ $stophere = null;
|
|
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $message, $match);
|
|
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $message, $match);
|
|
|
|
|
|
if ($this->markupgenerator !== NULL && !empty($match) && array_values($match)[0] !== NULL) {
|
|
if ($this->markupgenerator !== NULL && !empty($match) && array_values($match)[0] !== NULL) {
|
|
-
|
|
|
|
$url = is_array(array_values($match)[0]) ? array_values(array_values($match)[0])[0] : array_values($match)[0];
|
|
$url = is_array(array_values($match)[0]) ? array_values(array_values($match)[0])[0] : array_values($match)[0];
|
|
|
|
|
|
if (strpos($message, 'twitter')) {
|
|
if (strpos($message, 'twitter')) {
|
|
-
|
|
|
|
-
|
|
|
|
$statusTwitter = new StatusTwitter($url);
|
|
$statusTwitter = new StatusTwitter($url);
|
|
$nid = $statusTwitter->sendRequest();
|
|
$nid = $statusTwitter->sendRequest();
|
|
|
|
|
|
} else if (strpos($message, 'youtube') || strpos($message, 'youtu.be')) {
|
|
} else if (strpos($message, 'youtube') || strpos($message, 'youtu.be')) {
|
|
-
|
|
|
|
$statusYoutube = new StatusYoutube($url, $message);
|
|
$statusYoutube = new StatusYoutube($url, $message);
|
|
$nid = $statusYoutube->generateNode();
|
|
$nid = $statusYoutube->generateNode();
|
|
|
|
|
|
@@ -225,43 +220,41 @@ $stophere = null;
|
|
$nid = $statusHeartPost->sendRequest();
|
|
$nid = $statusHeartPost->sendRequest();
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if ($nid === NULL && !empty($this->statusTypeService)) {
|
|
if ($nid === NULL && !empty($this->statusTypeService)) {
|
|
- $statusCreated = false;
|
|
|
|
|
|
+ $sTypes = $this->statusTypeService->loadAll();
|
|
foreach ($this->statusTypeService->loadAll() as $type) {
|
|
foreach ($this->statusTypeService->loadAll() as $type) {
|
|
- if (!$statusCreated && !$type->getMedia()) {
|
|
|
|
-
|
|
|
|
- $userViewed = \Drupal::routeMatch()
|
|
|
|
- ->getParameters()
|
|
|
|
- ->get('user') === NULL ? \Drupal::currentUser()
|
|
|
|
- ->id() : \Drupal::routeMatch()
|
|
|
|
- ->getParameters()
|
|
|
|
- ->get('user')
|
|
|
|
- ->id();
|
|
|
|
-
|
|
|
|
- if ($userViewed !== NULL) {
|
|
|
|
-
|
|
|
|
- $statusEntity = Status::create([
|
|
|
|
- 'type' => $type->id(),
|
|
|
|
- 'uid' => \Drupal::currentUser()->id(),
|
|
|
|
- 'recipient' => $userViewed
|
|
|
|
- ]);
|
|
|
|
-
|
|
|
|
- $statusEntity->setMessage($message);
|
|
|
|
- if ($statusEntity->save()) {
|
|
|
|
- $statusCreated = TRUE;
|
|
|
|
- }
|
|
|
|
|
|
+ $userViewed = \Drupal::routeMatch()
|
|
|
|
+ ->getParameters()
|
|
|
|
+ ->get('user') === NULL ? \Drupal::currentUser()
|
|
|
|
+ ->id() : \Drupal::routeMatch()
|
|
|
|
+ ->getParameters()
|
|
|
|
+ ->get('user')
|
|
|
|
+ ->id();
|
|
|
|
+
|
|
|
|
+ if ($userViewed !== NULL) {
|
|
|
|
+ $statusEntity = Status::create([
|
|
|
|
+ 'type' => $type->id(),
|
|
|
|
+ 'uid' => \Drupal::currentUser()->id(),
|
|
|
|
+ 'recipient' => $userViewed
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ if ($type->getMedia() && $file !== null) {
|
|
|
|
+ $statusEntity->set('field_image', array_values($file)[0]);
|
|
}
|
|
}
|
|
|
|
+ $statusEntity->setMessage($message);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!empty($statusEntity) && $statusEntity->save()) {
|
|
|
|
+ //TODO Log or error report
|
|
|
|
+ $statusCreated = TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (\Drupal::service('module_handler')
|
|
if (\Drupal::service('module_handler')
|
|
- ->moduleExists('heartbeat') && ($nid !== NULL || $statusEntity !== NULL)
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
|
|
+ ->moduleExists('heartbeat') && ($nid !== NULL || $statusEntity !== NULL)) {
|
|
// $configManager = \Drupal::service('config.manager');
|
|
// $configManager = \Drupal::service('config.manager');
|
|
$feedConfig = \Drupal::config('heartbeat_feed.settings');
|
|
$feedConfig = \Drupal::config('heartbeat_feed.settings');
|
|
// $feedConfig = $feedConfig = $configManager->get('heartbeat_feed.settings');
|
|
// $feedConfig = $feedConfig = $configManager->get('heartbeat_feed.settings');
|