public function PhotosEditController::ajaxEditUpdateLoad in Album Photos 8.4
Ajax edit image load text.
1 string reference to 'PhotosEditController::ajaxEditUpdateLoad'
File
- src/
Controller/ PhotosEditController.php, line 273
Class
- PhotosEditController
- Edit images and image details.
Namespace
Drupal\photos\ControllerCode
public function ajaxEditUpdateLoad() {
$message = '';
$post_id = $this->requestStack
->getCurrentRequest()->request
->get('id');
if ($post_id) {
$id = Html::escape($post_id);
if (strstr($id, 'title')) {
$switch = 'title';
$fid = str_replace('photos-image-edit-title-', '', $id);
}
elseif (strstr($id, 'des')) {
$switch = 'des';
$fid = str_replace('photos-image-edit-des-', '', $id);
}
$fid = filter_var($fid, FILTER_SANITIZE_NUMBER_INT);
// Check user image edit permissions.
// @todo photos.routing.yml _csrf_token: 'TRUE'.
if ($fid && _photos_access('imageEdit', $fid)) {
switch ($switch) {
case 'title':
$value = $this->connection
->query("SELECT title FROM {photos_image} WHERE fid = :fid", [
':fid' => $fid,
])
->fetchField();
$message = $value;
break;
case 'des':
$value = $this->connection
->query("SELECT des FROM {photos_image} WHERE fid = :fid", [
':fid' => $fid,
])
->fetchField();
$message = $value;
break;
}
// Clear cache.
$pid = $this->connection
->query("SELECT pid FROM {photos_image} WHERE fid = :fid", [
':fid' => $fid,
])
->fetchField();
if ($pid) {
Cache::invalidateTags([
'node:' . $pid,
'photos:album:' . $pid,
]);
}
Cache::invalidateTags([
'photos:image:' . $fid,
]);
}
}
// Build plain text response.
$response = new Response();
$response->headers
->set('Content-Type', 'text/plain');
$response
->setContent($message);
return $response;
}