Revision history for RESTHandler


Revision [20112]

Last edited on 2008-06-30 17:15:14 by DomBonj [1.1.6.5 compatibility]
Additions:
- Wikka 1.1.6.4 & 1.1.6.5
2. In ##wikka.php##, go to line 378 [version 1.1.6.4 only] or to line 385 [version 1.1.6.5 only] and replace the following code block:
Deletions:
- Wikka 1.1.6.4
2. In ##wikka.php##, go to line 378 and replace the following code block:


Revision [20048]

Edited on 2008-06-22 10:01:30 by DomBonj [added PHP version check to Wakka.class.php]
Additions:
$output = (version_compare(PHP_VERSION, '5.0.0', '<')) ? '<Error>Unsupported: requires PHP version 5.0.0 or higher</Error>' : $this->Method('rest');
print ($output);
Deletions:
print($this->Method('rest'));


Revision [20043]

Edited on 2008-06-20 15:30:15 by DomBonj [v0.94: replaced empty parameter with '*' for mod_rewrite compatibity; HTTP status codes; error messa]
Additions:
# @version 0.94
# @output returns a XML document formatted as a UTF-8 string
# @uses Wakka::Format()
if (!defined('REST_ERROR_NOT_SUPPORTED')) define('REST_ERROR_NOT_SUPPORTED', 'MethodUnsupported');
if (!defined('REST_ERROR_SYNTAX')) define('REST_ERROR_SYNTAX', 'SyntaxError');
if (!defined('REST_ERROR_BAD_PARAMETERS')) define('REST_ERROR_BAD_PARAMETERS', 'IllegalParameters');
if (!defined('REST_ERROR_XPATH_FAILURE')) define('REST_ERROR_XPATH_FAILURE', 'XPathFailure');
if (!defined('REST_FORMAT_ERROR_MSG')) define('REST_FORMAT_ERROR_MSG', '<Error><Code>%s</Code><Message>%s</Message><Resource>%s %s</Resource></Error>');
$REST_RETURN_CODES_ARRAY = array(
'MethodUnsupported' => array('Method not supported', 'HTTP/1.1 501 Not Implemented'),
'SyntaxError' => array('Could not parse request string', 'HTTP/1.1 400 Bad Request'),
'IllegalParameters' => array('Illegal parameter(s) value', 'HTTP/1.1 400 Bad Request'),
'XPathFailure' => array('Could not process query', 'HTTP/1.1 500 Server Error')
);
function numeric_html_entities($string)
function uri_suffix_to_xpath_request(array $params)
$tag = isset($params[1]) ? ($params[1]!='*' ? $params[1] : '') : '';
$attr = isset($params[3]) ? ($params[3]!='*' ? $params[3] : '') : '';
$val = isset($params[5]) ? ($params[5]!='*' ? $params[5] : '') : '';
|| (!preg_match('/^([1-9][0-9]*)?$/', $rank))
$error_code = REST_ERROR_BAD_PARAMETERS;
$xpath .= $attr ? (($val ? '[contains(concat(concat(" ", @'. $attr. '), " "), concat(concat(" ", \''. $val .'\'), " "))]' : '[@'. $attr .']')) : '';
$error_code = '';
return(array($xpath, $rank, $error_code));
if ($_SERVER['REQUEST_METHOD'] != 'GET')
{ // not supported
$error_code = REST_ERROR_NOT_SUPPORTED;
elseif (preg_match('/^([a-zA-Z_\*][A-Za-z0-9:_\-\.]*)?(\/([a-zA-Z_*][A-Za-z0-9:_\-\.]*)?(\/([^\/]*))?(\/([^\/]*))?)?/', $this->RESTreq, $matches))
list($xpath_req, $rank, $error_code) = uri_suffix_to_xpath_request($matches);
$error_code = REST_ERROR_SYNTAX;
if (!$error_code)
$my_page = '<div class="page">'. "\n";
$my_page .= '<div style="clear: both"></div>'. "\n";
$error_code = REST_ERROR_XPATH_FAILURE;
if ($error_code)
{ // send 'Status' HTTP Header
header($REST_RETURN_CODES_ARRAY[$error_code][1]);
$output = sprintf(REST_FORMAT_ERROR_MSG, $error_code, $REST_RETURN_CODES_ARRAY[$error_code][0], $_SERVER['REQUEST_METHOD'], numeric_html_entities($this->RESTreq));
$output = '<wikkapage>'. $output .'</wikkapage>';
// the 'Content-Type' HTTP Header is sent in libs/Wakka.class.php
print ('<?xml version="1.0" encoding="utf-8" ?>'. "\n". $output);
Deletions:
# @version 0.93
# @output returns a UTF-8 string (empty if no match)
function numeric_html_entities ($string)
function uri_suffix_to_xpath_request (array $params)
$tag = isset($params[1]) ? $params[1] : '';
$attr = isset($params[3]) ? $params[3] : '';
$val = isset($params[5]) ? $params[5] : '';
|| (!preg_match('/^[0-9]*$/', $rank))
$xpath .= $attr ? ('[@'. $attr .($val ? '=\''.$val.'\'' : '') .']') : '';
return(array($xpath, $rank));
if (preg_match('/^([a-zA-Z_][A-Za-z0-9:_\-\.]*)?(\/([a-zA-Z_][A-Za-z0-9:_\-\.]*)?(\/([^\/]*))?(\/([^\/]*))?)?/', $this->RESTreq, $matches))
list($xpath_req, $rank) = uri_suffix_to_xpath_request($matches);
if ($xpath_req)
$my_page = '<div class="page">'."\n";
$my_page .= '<div style="clear: both"></div>'."\n";
{ // silent failure
$output = '';
// HTTP Header is sent in libs/Wakka.class.php
if ($output)
echo ('<page>'. $output .'</page>');
// else error message ?


Revision [20028]

Edited on 2008-06-09 16:18:00 by DomBonj [v0.93: bugfix: HTTP header sent twice; XML cleaning]
Additions:
# @version 0.93
# @uses Wakka::Href()
// if a '< ?xml version="1.0"? >' first line has been added, remove it
$output = preg_replace('/^\<\?xml[^\>]*?\>/i', '', $output);
// HTTP Header is sent in libs/Wakka.class.php
if ($output)
echo ('<page>'. $output .'</page>');
// else error message ?
header("Content-Type: text/xml; charset=utf-8");
Deletions:
# @version 0.92
Header("Content-Type: text/xml; charset=utf-8");
echo ('<page>'. $output .'</page>');


Revision [20022]

Edited on 2008-06-08 08:49:45 by DomBonj [v0.92: bugfix]
Additions:
# @version 0.92
Header("Content-Type: text/xml; charset=utf-8");
echo ('<page>'. $output .'</page>');
Deletions:
# @version 0.91
echo ($output);


Revision [20020]

The oldest known version of this page was created on 2008-06-08 07:57:31 by DomBonj [v0.92: bugfix]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki