1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8function smarty_function_service_inline($params, $smarty) 9{ 10 $servicelib = TikiLib::lib('service'); 11 12 if (! isset($params['controller'])) { 13 return 'missing-controller'; 14 } 15 if (! isset($params['action'])) { 16 return 'missing-action'; 17 } 18 $controller = $params['controller']; 19 $action = $params['action']; 20 unset($params['controller']); 21 unset($params['action']); 22 23 try { 24 $extensionPackage = ''; 25 if (strpos($controller, ".") !== false) { 26 $parts = explode(".", $controller); 27 if (count($parts) == 3) { 28 $extensionPackage = $parts[0] . "." . $parts[1]; 29 $controller = $parts[2]; 30 } 31 } 32 return $servicelib->render($controller, $action, $params, $extensionPackage); 33 } catch (Services_Exception $e) { 34 if (empty($params['_silent'])) { 35 $smarty->loadPlugin('smarty_block_remarksbox'); 36 $repeat = false; 37 return smarty_block_remarksbox(['type' => 'warning', 'title' => tr('Unavailable')], $e->getMessage(), $smarty, $repeat); 38 } 39 } 40} 41