Skip to content

Commit

Permalink
Issue CollaboraOnline#43: NULL, TRUE and FALSE in uppercase.
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed Nov 8, 2024
1 parent b0603ff commit 5363014
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions collabora_online.module
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ function collabora_online_entity_operation(EntityInterface $entity) {
'collabora_online_view' => [
'title' => t("View in Collabora Online"),
'weight' => 50,
'url' => CoolUtils::getEditorUrl($media, false),
'url' => CoolUtils::getEditorUrl($media, FALSE),
],
];

if (CoolUtils::canEdit($file) && $media->access('edit in collabora')) {
$entries['collabora_online_edit'] = [
'title' => t("Edit in Collabora Online"),
'weight' => 50,
'url' => CoolUtils::getEditorUrl($media, true),
'url' => CoolUtils::getEditorUrl($media, TRUE),
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/ViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function create(ContainerInterface $container): self {
* @return \Symfony\Component\HttpFoundation\Response
* Response suitable for iframe, without the usual page decorations.
*/
public function editor(Media $media, $edit = false) {
public function editor(Media $media, $edit = FALSE) {
$options = [
'closebutton' => 'true',
];
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function wopiCheckFileInfo(string $id, Request $request) {
$token = $request->query->get('access_token');

$jwt_payload = CoolUtils::verifyTokenForId($token, $id);
if ($jwt_payload == null) {
if ($jwt_payload == NULL) {
return static::permissionDenied();
}

Expand Down Expand Up @@ -123,7 +123,7 @@ public function wopiGetFile(string $id, Request $request) {
$token = $request->query->get('access_token');

$jwt_payload = CoolUtils::verifyTokenForId($token, $id);
if ($jwt_payload == null) {
if ($jwt_payload == NULL) {
return static::permissionDenied();
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public function wopiPutFile(string $id, Request $request) {
$exitsave = $request->headers->get('x-cool-wopi-isexitsave') == 'true';

$jwt_payload = CoolUtils::verifyTokenForId($token, $id);
if ($jwt_payload == null || !$jwt_payload->wri) {
if ($jwt_payload == NULL || !$jwt_payload->wri) {
return static::permissionDenied();
}

Expand Down
12 changes: 6 additions & 6 deletions src/Cool/CoolRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function getDiscovery($server) {
$discovery_url = $server . '/hosting/discovery';

$default_config = \Drupal::config('collabora_online.settings');
if ($default_config === null) {
return false;
if ($default_config === NULL) {
return FALSE;
}
$disable_checks = (bool) $default_config->get('cool')['disable_cert_check'];

Expand All @@ -53,14 +53,14 @@ function getDiscovery($server) {
* was found for the given MIME type.
*/
function getWopiSrcUrl($discovery_parsed, $mimetype) {
if ($discovery_parsed === null || $discovery_parsed == false) {
return null;
if ($discovery_parsed === NULL || $discovery_parsed == FALSE) {
return NULL;
}
$result = $discovery_parsed->xpath(sprintf('/wopi-discovery/net-zone/app[@name=\'%s\']/action', $mimetype));
if ($result && count($result) > 0) {
return $result[0]['urlsrc'];
}
return null;
return NULL;
}

/**
Expand Down Expand Up @@ -156,7 +156,7 @@ public function getWopiClientURL() {
}

$discovery = getDiscovery($wopi_client_server);
if ($discovery === false) {
if ($discovery === FALSE) {
$this->error_code = 203;
return NULL;
}
Expand Down
18 changes: 9 additions & 9 deletions src/Cool/CoolUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ public static function verifyTokenForId(
try {
$payload = JWT::decode($token, new Key($key, 'HS256'));

if ($payload && ($payload->fid == $id) && ($payload->exp >= gettimeofday(true))) {
if ($payload && ($payload->fid == $id) && ($payload->exp >= gettimeofday(TRUE))) {
return $payload;
}
}
catch (\Exception $e) {
\Drupal::logger('cool')->error($e->getMessage());
}
return null;
return NULL;
}

/**
Expand All @@ -127,7 +127,7 @@ public static function getAccessTokenTtl() {
$default_config = \Drupal::config('collabora_online.settings');
$ttl = $default_config->get('cool')['access_token_ttl'];

return gettimeofday(true) + $ttl;
return gettimeofday(TRUE) + $ttl;
}

/**
Expand Down Expand Up @@ -170,9 +170,9 @@ public static function tokenForFileId($id, $ttl, $can_write = FALSE) {
* List of read only formats. Currently limited to the one Drupal accept.
*/
const READ_ONLY = [
'application/x-iwork-keynote-sffkey' => true,
'application/x-iwork-pages-sffpages' => true,
'application/x-iwork-numbers-sffnumbers' => true,
'application/x-iwork-keynote-sffkey' => TRUE,
'application/x-iwork-pages-sffpages' => TRUE,
'application/x-iwork-numbers-sffnumbers' => TRUE,
];

/**
Expand Down Expand Up @@ -218,7 +218,7 @@ public static function getDocumentType(File $file) {
* @return \Drupal\Core\Url
* Editor url to visit as full-page, or to embed in an iframe.
*/
public static function getEditorUrl(Media $media, $can_write = false) {
public static function getEditorUrl(Media $media, $can_write = FALSE) {
if ($can_write) {
return Url::fromRoute('collabora-online.edit', ['media' => $media->id()]);
}
Expand All @@ -242,14 +242,14 @@ public static function getEditorUrl(Media $media, $can_write = false) {
* @return array|array{error: string}
* A stub render element array, or an array with an error on failure.
*/
public static function getViewerRender(Media $media, bool $can_write, $options = null) {
public static function getViewerRender(Media $media, bool $can_write, $options = NULL) {
$default_config = \Drupal::config('collabora_online.settings');
$wopi_base = $default_config->get('cool')['wopi_base'];
$allowfullscreen = $default_config->get('cool')['allowfullscreen'] ?? FALSE;

$req = new CoolRequest();
$wopi_client = $req->getWopiClientURL();
if ($wopi_client === null) {
if ($wopi_client === NULL) {
return [
'error' => t('The Collabora Online server is not available: ') . $req->errorString(),
];
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Field/FieldFormatter/CoolPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
}

foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) {
$url = CoolUtils::getEditorUrl($media, false);
$url = CoolUtils::getEditorUrl($media, FALSE);

$render_array = [
'#editorUrl' => $url,
Expand Down

0 comments on commit 5363014

Please sign in to comment.