Skip to content
This repository has been archived by the owner on Sep 10, 2023. It is now read-only.

Commit

Permalink
Merge branch 'development' of github.com:TextControl/txtextcontrol-re…
Browse files Browse the repository at this point in the history
…portingcloud-php into development
  • Loading branch information
jonathanmaron committed Feb 25, 2019
2 parents 625f2b7 + 2174081 commit 5157999
Show file tree
Hide file tree
Showing 26 changed files with 271 additions and 142 deletions.
9 changes: 4 additions & 5 deletions bin/build-cultures.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use TxTextControl\ReportingCloud\Assert\Assert;
use TxTextControl\ReportingCloud\Exception\RuntimeException;
use TxTextControl\ReportingCloud\Stdlib\ArrayUtils;
use TxTextControl\ReportingCloud\Stdlib\ConsoleUtils;

// ---------------------------------------------------------------------------------------------------------------------

Expand All @@ -44,7 +45,7 @@
}

if (0 === count($values)) {
$format = 'Cannot download the available cultures from %s';
$format = 'Cannot download the available cultures from "%s".';
$message = sprintf($format, $url);
throw new RuntimeException($message);
}
Expand All @@ -61,11 +62,9 @@
ArrayUtils::varExportToFile($filename, $values, $generator);

echo PHP_EOL;
echo sprintf('The available cultures (%d) are %s.', count($values), implode(', ', $values));
echo PHP_EOL;
echo PHP_EOL;
echo sprintf('Written data file to %s', $filename);
ConsoleUtils::writeLn('The available cultures (%d) are %s.', count($values), implode(', ', $values));
echo PHP_EOL;
ConsoleUtils::writeLn('Written data file to "%s".', $filename);
echo PHP_EOL;

// ---------------------------------------------------------------------------------------------------------------------
6 changes: 2 additions & 4 deletions bin/build-dictionaries.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@
ArrayUtils::varExportToFile($filename, $values, $generator);

echo PHP_EOL;
echo sprintf('The available dictionaries (%d) are %s.', count($values), implode(', ', $values));
echo PHP_EOL;
echo PHP_EOL;
echo sprintf('Written data file to %s', $filename);
ConsoleUtils::writeLn('The available dictionaries (%d) are %s.', count($values), implode(', ', $values));
echo PHP_EOL;
ConsoleUtils::writeLn('Written data file to "%s".', $filename);
echo PHP_EOL;

// ---------------------------------------------------------------------------------------------------------------------
25 changes: 10 additions & 15 deletions demo/api-key-management.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,16 @@

$reportingCloud = new ReportingCloud([
'api_key' => ConsoleUtils::apiKey(),
'test' => true,
]);

$apiKeys = $reportingCloud->getApiKeys();

if (!empty($apiKeys)) {
foreach ($apiKeys as $apiKey) {
if ($apiKey['key'] == ConsoleUtils::apiKey()) {
echo sprintf("Keeping API key %s...", $apiKey['key']);
echo PHP_EOL;
continue;
}
echo sprintf("Deleting API key %s...", $apiKey['key']);
echo PHP_EOL;
$reportingCloud->deleteApiKey($apiKey['key']);
unset($apiKey);
foreach ($reportingCloud->getApiKeys() as $apiKey) {
if ($apiKey['key'] === ConsoleUtils::apiKey()) {
ConsoleUtils::writeLn('Keeping API key "%s".', $apiKey['key']);
continue;
}
ConsoleUtils::writeLn('Deleting API key "%s".', $apiKey['key']);
$reportingCloud->deleteApiKey($apiKey['key']);
}

$newApiKey = $reportingCloud->createApiKey();
Expand All @@ -38,7 +32,8 @@
'api_key' => $newApiKey,
]);

dump($reportingCloud->getAccountSettings());
dump($reportingCloud->getTemplateList());
ConsoleUtils::dump($reportingCloud->getAccountSettings());

ConsoleUtils::dump($reportingCloud->getTemplateList());

// ---------------------------------------------------------------------------------------------------------------------
18 changes: 9 additions & 9 deletions demo/append-document-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,32 @@

$reportingCloud = new ReportingCloud([
'api_key' => ConsoleUtils::apiKey(),
'test' => true,
]);

$documents = [
[
'filename' => sprintf('%s/test_document.docx', Path::resource()),
'filename' => sprintf('%s/maelzel_machine.docx', Path::resource()),
'divider' => ReportingCloud::DOCUMENT_DIVIDER_NEW_SECTION,
],
[
'filename' => sprintf('%s/test_document.docx', Path::resource()),
'filename' => sprintf('%s/maelzel_machine.docx', Path::resource()),
'divider' => ReportingCloud::DOCUMENT_DIVIDER_NEW_SECTION,
],
[
'filename' => sprintf('%s/test_document.docx', Path::resource()),
'filename' => sprintf('%s/maelzel_machine.docx', Path::resource()),
'divider' => ReportingCloud::DOCUMENT_DIVIDER_NEW_SECTION,
],
];

$destinationFilename = sprintf('%s/test_append_document_advanced.pdf', Path::output());

$documentSettings = [
'author' => 'James Henry Trotter',
'author' => 'Wikipedia',
'creation_date' => time(),
'creator_application' => 'An awesome creator',
'document_subject' => 'The Old Green Grasshopper',
'document_title' => 'James and the Giant Peach',
'creator_application' => 'ReportingCloud PHP SDK',
'document_subject' => 'The Mechanical Turk',
'document_title' => 'Mälzel and the Machine',
'last_modification_date' => time(),
'user_password' => '1',
];
Expand All @@ -46,5 +47,4 @@

file_put_contents($destinationFilename, $binaryData);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);
10 changes: 5 additions & 5 deletions demo/append-document-basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@

$reportingCloud = new ReportingCloud([
'api_key' => ConsoleUtils::apiKey(),
'test' => true,
]);

$documents = [
[
'filename' => sprintf('%s/test_document.docx', Path::resource()),
'filename' => sprintf('%s/maelzel_machine.docx', Path::resource()),
'divider' => ReportingCloud::DOCUMENT_DIVIDER_NEW_SECTION,
],
[
'filename' => sprintf('%s/test_document.docx', Path::resource()),
'filename' => sprintf('%s/maelzel_machine.docx', Path::resource()),
'divider' => ReportingCloud::DOCUMENT_DIVIDER_NEW_SECTION,
],
[
'filename' => sprintf('%s/test_document.docx', Path::resource()),
'filename' => sprintf('%s/maelzel_machine.docx', Path::resource()),
'divider' => ReportingCloud::DOCUMENT_DIVIDER_NEW_SECTION,
],
];
Expand All @@ -35,5 +36,4 @@

file_put_contents($destinationFilename, $binaryData);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);
10 changes: 4 additions & 6 deletions demo/convert-document-docx-to-pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@
'api_key' => ConsoleUtils::apiKey(),
]);

$sourceFilename = sprintf('%s/test_document.docx', Path::resource());
$destinationFilename = sprintf('%s/test_document.pdf', Path::output());
$sourceFilename = sprintf('%s/maelzel_machine.docx', Path::resource());
$destinationFilename = sprintf('%s/maelzel_machine.pdf', Path::output());

$document = $reportingCloud->convertDocument(
$sourceFilename,
ReportingCloud::FILE_FORMAT_PDF
);

if (empty($document)) {
echo sprintf('Error converting "%s".', $sourceFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Error converting "%s".', $sourceFilename);
} else {
file_put_contents($destinationFilename, $document);
echo sprintf('"%s" was converted and written to "%s".', $sourceFilename, $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('"%s" was converted and written to "%s".', $sourceFilename, $destinationFilename);
}
10 changes: 4 additions & 6 deletions demo/convert-document-pdf-to-txt.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@
'api_key' => ConsoleUtils::apiKey(),
]);

$sourceFilename = sprintf('%s/camera_controls.pdf', Path::resource());
$destinationFilename = sprintf('%s/camera_controls.txt', Path::output());
$sourceFilename = sprintf('%s/maelzel_machine.pdf', Path::resource());
$destinationFilename = sprintf('%s/maelzel_machine.txt', Path::output());

$document = $reportingCloud->convertDocument(
$sourceFilename,
ReportingCloud::FILE_FORMAT_TXT
);

if (empty($document)) {
echo sprintf('Error converting "%s".', $sourceFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Error converting "%s".', $sourceFilename);
} else {
file_put_contents($destinationFilename, $document);
echo sprintf('"%s" was converted and written to "%s".', $sourceFilename, $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('"%s" was converted and written to "%s".', $sourceFilename, $destinationFilename);
}
3 changes: 1 addition & 2 deletions demo/find-and-replace-document.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@

file_put_contents($destinationFilename, $binaryData);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);
4 changes: 3 additions & 1 deletion demo/get-account-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
'api_key' => ConsoleUtils::apiKey(),
]);

dump($reportingCloud->getAccountSettings());
foreach ($reportingCloud->getAccountSettings() as $key => $value) {
ConsoleUtils::writeLn('- %s: %s', $key, $value);
}
2 changes: 1 addition & 1 deletion demo/get-template-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
$reportingCloud->uploadTemplate($sourceFilename);
}

dump($reportingCloud->getTemplateInfo($templateName));
ConsoleUtils::dump($reportingCloud->getTemplateInfo($templateName));
}
3 changes: 1 addition & 2 deletions demo/get-template-thumbnails.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@

file_put_contents($destinationFilename, $binaryData);

echo sprintf('"%s" was written to "%s".', $templateName, $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('"%s" was written to "%s".', $templateName, $destinationFilename);
}

// ---------------------------------------------------------------------------------------------------------------------
9 changes: 5 additions & 4 deletions demo/instantiation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
include_once __DIR__ . '/bootstrap.php';

use TxTextControl\ReportingCloud\ReportingCloud;
use TxTextControl\ReportingCloud\Stdlib\ConsoleUtils;

// ---------------------------------------------------------------------------------------------------------------------

Expand All @@ -13,7 +14,7 @@
'api_key' => 'xxxxxxxx',
]);

dump($reportingCloud);
ConsoleUtils::dump($reportingCloud);

// ---------------------------------------------------------------------------------------------------------------------

Expand All @@ -23,7 +24,7 @@

$reportingCloud->setApiKey('xxxxxxxx');

dump($reportingCloud);
ConsoleUtils::dump($reportingCloud);

// ---------------------------------------------------------------------------------------------------------------------

Expand All @@ -39,7 +40,7 @@
'debug' => true,
]);

dump($reportingCloud);
ConsoleUtils::dump($reportingCloud);

// ---------------------------------------------------------------------------------------------------------------------

Expand All @@ -55,6 +56,6 @@
$reportingCloud->setTimeout(100);
$reportingCloud->setDebug(true);

dump($reportingCloud);
ConsoleUtils::dump($reportingCloud);

// ---------------------------------------------------------------------------------------------------------------------
4 changes: 3 additions & 1 deletion demo/list-fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
'api_key' => ConsoleUtils::apiKey(),
]);

dump($reportingCloud->getFontList());
foreach ($reportingCloud->getFontList() as $font) {
ConsoleUtils::writeLn('- %s', $font);
}
16 changes: 5 additions & 11 deletions demo/merge-document-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

$reportingCloud = new ReportingCloud([
'api_key' => ConsoleUtils::apiKey(),
'test' => true,
]);

// ---------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -98,8 +97,7 @@

file_put_contents($destinationFilename, $arrayOfBinaryData[0]);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);

// ---------------------------------------------------------------------------------------------------------------------

Expand All @@ -125,8 +123,7 @@

file_put_contents($destinationFilename, $arrayOfBinaryData[0]);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);

// ---------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -172,8 +169,7 @@

file_put_contents($destinationFilename, $arrayOfBinaryData[0]);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);

// ---------------------------------------------------------------------------------------------------------------------

Expand All @@ -200,8 +196,7 @@

file_put_contents($destinationFilename, $arrayOfBinaryData[0]);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);

// ---------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -236,8 +231,7 @@

file_put_contents($destinationFilename, $binaryData);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);
}

// ---------------------------------------------------------------------------------------------------------------------
3 changes: 1 addition & 2 deletions demo/merge-document-basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@

file_put_contents($destinationFilename, $arrayOfBinaryData[0]);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);
3 changes: 1 addition & 2 deletions demo/merge-document-html.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,4 @@

file_put_contents($destinationFilename, $arrayOfBinaryData[0]);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);
3 changes: 1 addition & 2 deletions demo/merge-document-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@

file_put_contents($destinationFilename, $arrayOfBinaryData[0]);

echo sprintf('Written to "%s".', $destinationFilename);
echo PHP_EOL;
ConsoleUtils::writeLn('Written to "%s".', $destinationFilename);
6 changes: 3 additions & 3 deletions demo/proofing.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
'api_key' => ConsoleUtils::apiKey(),
]);

dump($reportingCloud->getAvailableDictionaries());
ConsoleUtils::dump($reportingCloud->getAvailableDictionaries());

dump($reportingCloud->getProofingSuggestions('ssky', 'en_US.dic', 10));
ConsoleUtils::dump($reportingCloud->getProofingSuggestions('ssky', 'en_US.dic', 10));

dump($reportingCloud->proofingCheck('Thiss is a testt about rockkets in the ssky', 'en_US.dic'));
ConsoleUtils::dump($reportingCloud->proofingCheck('Thiss is a testt about rockkets in the ssky', 'en_US.dic'));
Loading

0 comments on commit 5157999

Please sign in to comment.