Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehudson committed Jul 7, 2022
2 parents b90486c + b9e83d4 commit 016c21c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Evernote Cloud SDK 2.0 for PHP (beta)
Evernote Cloud SDK PHP v2.0.2
=====================================

A newly-redesigned, simple, workflow-oriented library built on the Evernote Cloud API. It's designed to drop into your web app easily and make most common Evernote integrations very simple to accomplish. (And even the more complex integrations easier than they used to be.)
Expand All @@ -12,7 +12,7 @@ Just run these two commands to install it:

``` bash
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require evernote/evernote-cloud-sdk-php dev-master
$ php composer.phar require evernote/evernote-cloud-sdk-php
```

Now you can add the autoloader, and you will have access to the library:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"sdk"
],
"homepage": "https://github.com/evernote/evernote-cloud-sdk-php",
"version": "2.0",
"version": "2.0.2",
"license": "Apache",
"authors": [
{
Expand All @@ -23,8 +23,8 @@
},
"require": {
"php": ">=5.3",
"ezyang/htmlpurifier": "~4.6.0",
"tijsverkoyen/css-to-inline-styles": "~1.5",
"ezyang/htmlpurifier": "^4.6.0",
"tijsverkoyen/css-to-inline-styles": "~2.2",
"psr/log": "~1.0"
},
"autoload": {
Expand Down
6 changes: 4 additions & 2 deletions src/Evernote/Auth/OauthHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ public function authorize($consumer_key, $consumer_secret, $callback)

$this->consumer_secret = $consumer_secret;

if (session_status() == PHP_SESSION_NONE) {
session_start();
}

// first call
if (!array_key_exists('oauth_verifier', $_GET) && !array_key_exists('oauth_token', $_GET)) {
session_start();
unset($this->params['oauth_token']);
unset($this->params['oauth_verifier']);

Expand All @@ -68,7 +71,6 @@ public function authorize($consumer_key, $consumer_secret, $callback)
throw new AuthorizationDeniedException('Authorization declined.');
//the user authorized the app
} else {
session_start();
$this->token_secret = $_SESSION['oauth_token_secret'];

$this->params['oauth_token'] = $_GET['oauth_token'];
Expand Down
2 changes: 1 addition & 1 deletion src/Evernote/Enml/Converter/HtmlToEnmlConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function convertToEnml($content, $base_url = null)
$content = $this->cleanHtml($content);

//Transform to ENML via XSLT
$enml_body = $this->xslTransform($content, 'html2enml.xslt');
$enml_body = $this->xslTransform($content, __DIR__ . '/html2enml.xslt');

$enml = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
Expand Down
25 changes: 21 additions & 4 deletions src/Evernote/Model/EnmlNoteContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ class EnmlNoteContent extends NoteContent implements NoteContentInterface

public function __construct($content, HtmlConverterInterface $htmlConverter = null)
{
if (!$this->hasDoctypeDeclaration($content)) {
$content = $this->addDoctypeDeclaration($content);
}

if (!$this->hasXmlDeclaration($content)) {
$content = $this->decorate($content);
$content = $this->addXmlDeclaration($content);
}

$this->content = $content;
Expand Down Expand Up @@ -57,14 +61,27 @@ protected function hasXmlDeclaration($content)
{
return substr(trim($content), 0, 5) == '<?xml';
}

protected function decorate($content)

protected function hasDoctypeDeclaration($content)
{
return strpos($content, '<!DOCTYPE') !== false;
}

protected function addXmlDeclaration($content)
{
return <<<ENML
<?xml version='1.0' encoding='utf-8'?>
$content
ENML;

}

protected function addDoctypeDeclaration($content)
{
return <<<ENML
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note>$content</en-note>
ENML;

}
}
}

0 comments on commit 016c21c

Please sign in to comment.