Skip to content

Commit

Permalink
Issue #43: NULL, TRUE and FALSE in uppercase.
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote authored and hfiguiere committed Nov 15, 2024
1 parent 074aeef commit b60be72
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 @@ -49,7 +49,7 @@ public static function create(ContainerInterface $container): self {
*
* @return Response
*/
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 @@ -44,7 +44,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 @@ -101,7 +101,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 @@ -129,7 +129,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 @@ -21,8 +21,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 @@ -36,14 +36,14 @@ function getDiscovery($server) {
}

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;
}

function strStartsWith($s, $ss) {
Expand Down Expand Up @@ -99,7 +99,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 @@ -64,14 +64,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 @@ -81,7 +81,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 @@ -116,9 +116,9 @@ public static function tokenForFileId($id, $ttl, $can_write = FALSE) {
* 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 All @@ -140,7 +140,7 @@ public static function getDocumentType(File $file) {
}

/** Return the editor / viewer Drupal URL from the routes configured. */
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 @@ -163,14 +163,14 @@ public static function getEditorUrl(Media $media, $can_write = false) {
* Options for the renderer. Current values:
* - "closebutton" if "true" will add a close box. (see COOL SDK)
*/
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 b60be72

Please sign in to comment.