-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a consumer class for the pages API. Fixed the events API so that…
… it returns the proper data. Modified README * Removed the documentation which shows the main function as findById. Modified lib/base.php * parametersToUrl: Removed the resource, ID and extension parameters. Now it just inputs a baseUrl parameter that the calling method provides. It's much more flexible and fits with services like the page service. Modified lib/document.php * Switched all methods to use the new parametersToUrl function. Modified lib/event.php * findAll: Now uses the new parametersToUrl signature. Now uses the nodeValue and NodeValueInt methods for loading the proper XML response. Modified lib/service.php * Updated version number to 2.2.0. Added lib/page.php * New class that consumes the Page API service to return page numbers and text. Modified lib/vuzit.php * Added the page.php class file. Modified test/index.html * Added notes for the page class. Modified test/test.php * event_load_html: Now properly checks if the page number is -1 which means that there is no page present. * page_command: Loads and displays the page text information.
- Loading branch information
Showing
9 changed files
with
159 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
/* | ||
Class for loading page text. To use this class you need to sign up | ||
for Vuzit first: http://vuzit.com/signup | ||
*/ | ||
class Vuzit_Page extends Vuzit_Base | ||
{ | ||
/* | ||
Constructor. Creates an empty page object. This is not called directly. | ||
Use findAll to load an instance. | ||
*/ | ||
public function __construct() { | ||
$this->pageNumber = -1; | ||
$this->pageText = null; | ||
} | ||
|
||
/* | ||
Returns the page number of the page. | ||
*/ | ||
public function getNumber() { | ||
return $this->pageNumber; | ||
} | ||
|
||
/* | ||
Returns the page text. | ||
*/ | ||
public function getText() { | ||
return $this->pageText; | ||
} | ||
|
||
/* | ||
Loads an array of pages. It throws a <Vuzit_ClientException> on failure. | ||
*/ | ||
public static function findAll($webId, $options = null) | ||
{ | ||
if(!$webId) { | ||
throw new Vuzit_ClientException("No webId parameter specified"); | ||
} | ||
|
||
$params = self::postParameters("index", $options, $webId); | ||
|
||
$ch = self::curlRequest(); | ||
$url = self::parametersToUrl("documents/$webId/pages.xml", $params); | ||
|
||
curl_setopt($ch, CURLOPT_URL, $url); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // only if expecting response | ||
|
||
$xml_string = curl_exec($ch); | ||
$info = curl_getinfo($ch); | ||
|
||
if(!$xml_string) { | ||
throw new Vuzit_ClientException('CURL load failed: "' . curl_error($ch) . '"'); | ||
} | ||
|
||
// Prevent the warnings if the XML is malformed | ||
$xml = @simplexml_load_string($xml_string); | ||
curl_close($ch); | ||
|
||
if(!$xml) { | ||
throw new Vuzit_ClientException("Error loading XML response"); | ||
} | ||
if($xml->code) { | ||
throw new Vuzit_ClientException($xml->msg, (int)$xml->code); | ||
} | ||
if(!$xml->page) { | ||
throw new Vuzit_ClientException("Unknown error occurred"); | ||
} | ||
|
||
$result = array(); | ||
|
||
foreach($xml->page as $node) | ||
{ | ||
$page = new Vuzit_Page(); | ||
$page->pageNumber = self::nodeValueInt($node->number); | ||
$page->pageText = self::nodeValue($node->text); | ||
|
||
$result[] = $page; | ||
} | ||
|
||
return $result; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters