| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
require('list.php'); |
|---|
| 10 |
class org_routamc_photostream_handler_feed extends org_routamc_photostream_handler_list |
|---|
| 11 |
{ |
|---|
| 12 |
|
|---|
| 13 |
* Simple default constructor. |
|---|
| 14 |
*/ |
|---|
| 15 |
function org_routamc_photostream_handler_feed() |
|---|
| 16 |
{ |
|---|
| 17 |
parent::org_routamc_photostream_handler_list(); |
|---|
| 18 |
} |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
* Overloaded since we really dont' need those |
|---|
| 22 |
*/ |
|---|
| 23 |
function _prepare_ajax_controllers() |
|---|
| 24 |
{ |
|---|
| 25 |
|
|---|
| 26 |
return; |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
* This rather sneaky dispatcher is able to create a feed from any |
|---|
| 31 |
* request_switch supported by org_routamc_photostream_handler_list |
|---|
| 32 |
* that populates $data['photos'] (with a little help from org_routamc_photostream_viewer) |
|---|
| 33 |
*/ |
|---|
| 34 |
function _handler_dispatcher($handler_id, $args, &$data) |
|---|
| 35 |
{ |
|---|
| 36 |
debug_push_class(__CLASS__, __FUNCTION__); |
|---|
| 37 |
$parent_handler_id = preg_replace('/^feed:/', '', $handler_id); |
|---|
| 38 |
if (!isset($data['request_switch'][$parent_handler_id])) |
|---|
| 39 |
{ |
|---|
| 40 |
|
|---|
| 41 |
debug_add("Cannot find handler_id '{$parent_handler_id}'", MIDCOM_LOG_ERROR); |
|---|
| 42 |
debug_pop(); |
|---|
| 43 |
return false; |
|---|
| 44 |
} |
|---|
| 45 |
$parent_method = "_handler_{$data['request_switch'][$parent_handler_id]['handler'][1]}"; |
|---|
| 46 |
debug_add("Resolved parent method to '{$parent_method}'"); |
|---|
| 47 |
|
|---|
| 48 |
unset($data['request_switch']); |
|---|
| 49 |
|
|---|
| 50 |
if (!is_callable(array($this, $parent_method))) |
|---|
| 51 |
{ |
|---|
| 52 |
|
|---|
| 53 |
debug_add("Handler method \$this->{$parent_method} is not callable", MIDCOM_LOG_ERROR); |
|---|
| 54 |
debug_pop(); |
|---|
| 55 |
return false; |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
$data['feed_type_arg'] = array_pop($args); |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
debug_add("Calling \$this->{$parent_method}('{$parent_handler_id}', \$args, \$data)"); |
|---|
| 63 |
if (!$this->$parent_method($parent_handler_id, $args, $data)) |
|---|
| 64 |
{ |
|---|
| 65 |
debug_add("\$this->{$parent_method}('{$parent_handler_id}', \$args, \$data) returned false", MIDCOM_LOG_ERROR); |
|---|
| 66 |
debug_pop(); |
|---|
| 67 |
return false; |
|---|
| 68 |
} |
|---|
| 69 |
if (!isset($data['photos'])) |
|---|
| 70 |
{ |
|---|
| 71 |
debug_add("\$data['photos'] is not set, most probably we hit a method ('{$parent_method}') in the list handler that does not populate it", MIDCOM_LOG_WARN); |
|---|
| 72 |
debug_pop(); |
|---|
| 73 |
|
|---|
| 74 |
$_MIDCOM->generate_error(MIDCOM_ERR_NOTFOUND); |
|---|
| 75 |
// This will exit |
|---|
| 76 |
*/ |
|---|
| 77 |
return false; |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
debug_pop(); |
|---|
| 81 |
return true; |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
function _show_dispatcher($handler_id, &$data) |
|---|
| 85 |
{ |
|---|
| 86 |
echo "<p>Handler '{$handler_id}' says: Hello world!</p>"; |
|---|
| 87 |
|
|---|
| 88 |
echo "request_data: <pre>\n"; |
|---|
| 89 |
print_r($data); |
|---|
| 90 |
echo "</pre>\n"; |
|---|
| 91 |
*/ |
|---|
| 92 |
} |
|---|
| 93 |
} |
|---|
| 94 |
?> |
|---|