Skip to content

Commit

Permalink
Merge pull request #11 from donquixote/issue-43-phpcs
Browse files Browse the repository at this point in the history
Issue CollaboraOnline#43: Introduce phpcs, add meaningful doc comments.
  • Loading branch information
donquixote authored and AaronGilMartinez committed Nov 25, 2024
2 parents ea3f6aa + 2dcdc06 commit 2dc8e3d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 47 deletions.
76 changes: 38 additions & 38 deletions collabora_online.module
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,44 @@ use Drupal\media\MediaInterface;
*/
function collabora_online_theme($existing, $type, $theme, $path) {

return [
'collabora_online' => [
'render element' => 'children',
'template' => 'collabora-online',
'variables' => [
'accessToken' => 'test',
'accessTokenTtl' => '86400',
'iFrameStyle' => 'width:95%;',
'closebutton' => '',
'allowfullscreen' => '',
'wopiSrc' => 'http://localhost:9980/',
'wopiClient' => 'https://localhost:9980/',
],
],
// This is the template for the field preview.
'collabora_online_preview' => [
'render element' => 'children',
'template' => 'collabora-online-preview',
'variables' => [
'editorUrl' => 'about:blank',
'fileName' => '',
],
],
// This is the template for the complete page with embedding.
'collabora_online_full' => [
'template' => 'collabora-online-full',
'variables' => [
'accessToken' => 'test',
'accessTokenTtl' => '86400',
'iFrameStyle' => '',
'closebutton' => '',
'allowfullscreen' => '',
'wopiSrc' => '/wopi/files/123',
'wopiClient' => 'https://localhost:9980/',
],
'file' => 'collabora_online.theme.inc',
],
];
return [
'collabora_online' => [
'render element' => 'children',
'template' => 'collabora-online',
'variables' => [
'accessToken' => 'test',
'accessTokenTtl' => '86400',
'iFrameStyle' => 'width:95%;',
'closebutton' => '',
'allowfullscreen' => '',
'wopiSrc' => 'http://localhost:9980/',
'wopiClient' => 'https://localhost:9980/',
],
],
// This is the template for the field preview.
'collabora_online_preview' => [
'render element' => 'children',
'template' => 'collabora-online-preview',
'variables' => [
'editorUrl' => 'about:blank',
'fileName' => '',
],
],
// This is the template for the complete page with embedding.
'collabora_online_full' => [
'template' => 'collabora-online-full',
'variables' => [
'accessToken' => 'test',
'accessTokenTtl' => '86400',
'iFrameStyle' => '',
'closebutton' => '',
'allowfullscreen' => '',
'wopiSrc' => '/wopi/files/123',
'wopiClient' => 'https://localhost:9980/',
],
'file' => 'collabora_online.theme.inc',
],
];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/WopiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function wopiGetFile(string $id, Request $request) {
}

/**
* Handles the wopi "save" request for a media entity.
* Handles the wopi "save" request for a media entity..
*
* @param string $id
* Media id from url.
Expand Down
4 changes: 2 additions & 2 deletions src/Cool/CoolRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ function getDiscovery($server) {

$stream_context = stream_context_create([
'ssl' => [
'verify_peer' => !$disable_checks,
'verify_peer_name' => !$disable_checks,
'verify_peer' => !$disable_checks,
'verify_peer_name' => !$disable_checks,
],
]);
$res = file_get_contents($discovery_url, FALSE, $stream_context);
Expand Down
6 changes: 2 additions & 4 deletions src/Cool/CoolUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ public static function verifyTokenForId(
if ($payload && ($payload->fid == $id) && ($payload->exp >= gettimeofday(TRUE))) {
return $payload;
}
}
catch (\Exception $e) {
} catch (\Exception $e) {
\Drupal::logger('cool')->error($e->getMessage());
}
return NULL;
Expand Down Expand Up @@ -221,8 +220,7 @@ public static function getDocumentType(File $file) {
public static function getEditorUrl(Media $media, $can_write = FALSE) {
if ($can_write) {
return Url::fromRoute('collabora-online.edit', ['media' => $media->id()]);
}
else {
} else {
return Url::fromRoute('collabora-online.view', ['media' => $media->id()]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/ExistingSiteJavascript/CollaboraIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public function testCollaboraPreview(): void {

$document_field = $assert_session->waitForElement('css', 'input#document-name-input');
$this->assertNotNull($document_field, 'The document name input was not found after 10 seconds.');
$this->getCurrentPage()->waitFor(10, function() use ($document_field) {
$this->getCurrentPage()->waitFor(10, function () use ($document_field) {
return $document_field->getValue() === 'shopping-list.txt';
});
$this->assertEquals('shopping-list.txt', $document_field->getValue(), 'The document name input did not contain the correct value after 10 seconds.');

$word_count_element = $assert_session->waitForElement('css', 'div#StateWordCount');
$this->assertNotNull($word_count_element, 'The word count element was not found after 10 seconds.');
$this->getCurrentPage()->waitFor(10, function() use ($word_count_element) {
$this->getCurrentPage()->waitFor(10, function () use ($word_count_element) {
return $word_count_element->getText() === '2 words, 18 characters';
});
$this->assertEquals('2 words, 18 characters', $word_count_element->getText(), 'The word count element did not contain the correct text after 10 seconds.');
Expand Down

0 comments on commit 2dc8e3d

Please sign in to comment.