Index: /branches/MidCOM_2_8/org.routamc.photostream/viewer.php =================================================================== --- /branches/MidCOM_2_8/org.routamc.photostream/viewer.php (revision 10969) +++ /branches/MidCOM_2_8/org.routamc.photostream/viewer.php (revision 11036) @@ -329,4 +329,48 @@ ), ); + + $this->_register_feed_handlers(); + } + + function _register_feed_handlers() + { + debug_push_class(__CLASS__, __FUNCTION__); + debug_print_r('$this->_request_switch is now: ', $this->_request_switch); + debug_add('Start'); + foreach ($this->_request_switch as $handler_id => $switch_data) + { + debug_add("Checking id '{$handler_id}', it has handler class '{$switch_data['handler'][0]}'"); + if ($switch_data['handler'][0] !== 'org_routamc_photostream_handler_list') + { + debug_add('Not interested, next!'); + // We only care about the list views + continue; + } + $new_id = "feed:{$handler_id}"; + debug_add("Creating new switch with id '{$new_id}'"); + // PHP5-TODO: Must be copy-by-value + $new_switch = $switch_data; + // switch handler to the feed dispatcher + $new_switch['handler'] = array('org_routamc_photostream_handler_feed', 'dispatcher'); + // add a variable arg to end of list for feed type + if (!isset($new_switch['variable_args'])) + { + $new_switch['variable_args'] = 0; + } + $new_switch['variable_args']++; + + /* OTOH the variable_args increment server the same purpose and it's easier to just add rss.xml/atom.xml to the url... + // Prepend /feed/ to list fixed args + array_unshift($new_switch['fixed_args'], 'feed'); + */ + + // Add the new switch + debug_print_r("Setting \$this->_request_switch['{$new_id}'] to: ", $new_switch); + $this->_request_switch[$new_id] = $new_switch; + unset($new_id, $new_switch); + } + debug_add('Done.'); + debug_print_r('$this->_request_switch is now: ', $this->_request_switch); + debug_pop(); } @@ -442,4 +486,6 @@ ); + // the feed dispatcher needs this information, it might be available otherwisely but I couldn't find it + $this->_request_data['request_switch'] =& $this->_request_switch; return true; } Index: /branches/MidCOM_2_8/org.routamc.photostream/handler/feed.php =================================================================== --- /branches/MidCOM_2_8/org.routamc.photostream/handler/feed.php (revision 11036) +++ /branches/MidCOM_2_8/org.routamc.photostream/handler/feed.php (revision 11036) @@ -0,0 +1,94 @@ +{$parent_method} is not callable", MIDCOM_LOG_ERROR); + debug_pop(); + return false; + } + // Use array_pop so we can pass the args on to the parent handler and it will not get confused by too long argument list + $data['feed_type_arg'] = array_pop($args); + + // TODO: Validate feed type before continuing + + debug_add("Calling \$this->{$parent_method}('{$parent_handler_id}', \$args, \$data)"); + if (!$this->$parent_method($parent_handler_id, $args, $data)) + { + debug_add("\$this->{$parent_method}('{$parent_handler_id}', \$args, \$data) returned false", MIDCOM_LOG_ERROR); + debug_pop(); + return false; + } + if (!isset($data['photos'])) + { + 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); + debug_pop(); + /* TODO: Check if this is correct way + $_MIDCOM->generate_error(MIDCOM_ERR_NOTFOUND); + // This will exit + */ + return false; + } + + debug_pop(); + return true; + } + + function _show_dispatcher($handler_id, &$data) + { + echo "
Handler '{$handler_id}' says: Hello world!
"; + /* + echo "request_data:\n"; + print_r($data); + echo "\n"; + */ + } +} +?>