Vivvo Actions & Services in General

Each Actions must be registered in Vivvo configuration storage before it can be used.

Example

You can find default Vivvo Actions and Services in /lib/vivvo/service/ folder, feel free to analyze them.

This is an example of actions for Vivvo's Comments.

	$service_definition = array(
		"comment.add" => array(
			"function" => "comment_service",
			"signature" => array(array('bool', 'string','integer')),
			"docstring" => 'Add new comment.'
		),
		...
		"comment.vote" => array(
			"function" => "comment_service",
			"signature" => array(array('bool', 'ineteger', 'ineteger')),
			"docstring" => 'Vote'
		)
	);
	function comment_service(&$sm, $action, $command){
		require_once(dirname(__FILE__) . '/Comments.service.php');
		$comment_service =& new comment_service($sm);
		$um =& $sm->get_url_manager();
		$dm =& $sm->get_dump_manager();
		$lang =& $sm->get_lang();
		if ($command == 'add'){
			$in_comment = $um->get_param_regexp('/^COMMENT_/');
			$captcha = $um->get_param('COMMENT_captcha');
			$response = $comment_service->add_comment($in_comment, $captcha);
			if ($response){
				$dm->add_dump('info', 0 , $lang->get_value('LNG_INFO_COMMENT_ADD_SUCCESS'));
				return true;
			}else{
				return false;
			}
		...
		}elseif($command == 'vote'){
			$comment_id = $um->get_param('COMMENT_id');
			$vote = $um->get_param('COMMENT_vote');
			$response = $comment_service->vote($comment_id, $vote);
			if ($response){
				return true;
			}else{
				return false;
			}
		}
		return true;
	}

Array $service_definition contains list of commands. Name of command in this array contains two word. First word is action and second word is command. Each name has information about main function, signature and docstring. Vivvo detects all $service_definition and if find action which user

 
devdoc/css.txt · Last modified: 2010/05/05 17:08 by damir
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki