From 5fcbb062de07eba1202217f418ca9c6b9c3b5cff Mon Sep 17 00:00:00 2001 From: alvaro <alvaro@alia.(none)> Date: Thu, 15 Mar 2012 23:27:31 -0700 Subject: [PATCH] Removed old SpecialFunction files that aren't used anymore --- classes/AbstractSpecialFunction.php | 10 --- classes/BasicSpecialFunction.php | 119 ---------------------------- classes/modules/serviceModule.php | 2 - common.inc.php | 1 - 4 files changed, 132 deletions(-) delete mode 100644 classes/AbstractSpecialFunction.php delete mode 100644 classes/BasicSpecialFunction.php diff --git a/classes/AbstractSpecialFunction.php b/classes/AbstractSpecialFunction.php deleted file mode 100644 index 1865981a..00000000 --- a/classes/AbstractSpecialFunction.php +++ /dev/null @@ -1,10 +0,0 @@ -<? - -abstract class AbstractSpecialFunction{ - abstract protected function getFunction($uri); - abstract protected function getParams($uri); - abstract public function execute($uri, $context); - -} - -?> diff --git a/classes/BasicSpecialFunction.php b/classes/BasicSpecialFunction.php deleted file mode 100644 index 3a4f2977..00000000 --- a/classes/BasicSpecialFunction.php +++ /dev/null @@ -1,119 +0,0 @@ -<? - -include_once('AbstractSpecialFunction.php'); - -class SpecialFunction extends AbstractSpecialFunction{ - protected function getFunction($uri){ - global $conf; - $count = 1; - $prefixUri = $conf['basedir']; - $aux = str_replace($prefixUri, '', $uri, $count); - $functionAndParams = explode('/', $aux); - return $functionAndParams[0]; - } - - protected function getParams($uri){ - global $conf; - $count = 1; - $prefixUri = $conf['basedir']; - $functionAndParams = explode('/', str_replace($prefixUri, '', $uri, $count)); - if(sizeof($functionAndParams) > 1){ - array_shift($functionAndParams); - return $functionAndParams; - }else{ - return array(null); - } - } - - public function execute($uri, $context){ - global $conf; - global $lodspk; - global $results; - global $rRoot; - $f = $this->getFunction($uri); - $params = array(); - $params = $this->getParams($uri); - //$params[] = $context; - $acceptContentType = Utils::getBestContentType($_SERVER['HTTP_ACCEPT']); - $extension = Utils::getExtension($acceptContentType); - $args = array(); - try{ - $viewFile = $conf['service']['prefix'].$f."/".$extension.".template"; - $modelFile = $conf['service']['prefix'].$f."/".$extension.".queries"; - if(!(is_dir($conf['model']['directory'].$modelFile) || is_file($conf['model']['directory'].$modelFile))){ - $msg = '<h1>Method does not exist!</h1><br/>This means that <tt>'.$modelFile."</tt> doesn't exist.<br/>Please refer to this tutorial to create one.<br/>"; - throw new Exception($msg); - } - if(!is_file($conf['view']['directory'].$viewFile)){ - $msg='<h1>Method does not exist!</h1><br/>This means that <tt>'.$conf['view']['directory'].$viewFile."</tt> doesn't exist.<br/>Please refer to this tutorial to create one.<br/>"; - throw new Exception($msg); - } - $endpoints = $context['endpoints']; - //array_pop($params); - //array_shift($params); - - $prefixHeader = array(); - - for($i=0;$i<sizeof($params);$i++){ - if($conf['mirror_external_uris']){ - $altUri = Utils::curie2uri($params[$i]); - $altUri = preg_replace("|^".$conf['basedir']."|", $conf['ns']['local'], $altUri); - $params[$i] = Utils::uri2curie($altUri); - } - } - - for($i=0;$i<sizeof($params);$i++){ - $auxPrefix = Utils::getPrefix($params[$i]); - if($auxPrefix['ns'] != NULL){ - $prefixHeader[] = $auxPrefix; - } - $args["arg".$i]=$params[$i]; - } - $results['params'] = $params; - $lodspk = $conf['view']['standard']; - $lodspk['type'] = $modelFile; - $lodspk['root'] = $conf['root']; - $lodspk['home'] = $conf['basedir']; - $lodspk['this']['value'] = $uri; - $lodspk['this']['curie'] = Utils::uri2curie($uri); - $lodspk['this']['contentType'] = $acceptContentType; - $lodspk['model']['directory'] = $conf['model']['directory']; - $lodspk['view']['directory'] = $conf['view']['directory']; - $lodspk['ns'] = $conf['ns']; - $lodspk['endpoint'] = $conf['endpoint']; - $lodspk['type'] = $modelFile; - $lodspk['header'] = $prefixHeader; - $lodspk['args'] = $args; - $lodspk['module'] = 'service'; - $lodspk['add_mirrored_uris'] = false; - $lodspk['baseUrl'] = $conf['basedir']; - $lodspk['this']['value'] = $uri; - $lodspk['this']['contentType'] = $acceptContentType; - $lodspk['view']['directory'] = $conf['home'].$conf['view']['directory'].$conf['service']['prefix'].$f.'/'; - $lodspk['model']['directory'] = $conf['home'].$conf['model']['directory']; - chdir($conf['model']['directory']); - $first = array(); - Utils::queryFile($modelFile, $endpoints['local'], $results, $first); - chdir($conf['home']); - $results = Utils::internalize($results); - - if(is_array($results)){ - $results = Convert::array_to_object($results); - } - - //Need to redefine viewFile as 'local' i.e., inside service.foo/ so I can load files with the relative path correctly - $viewFile = $extension.".template"; - Utils::processDocument($viewFile, $lodspk, $results); - - }catch (Exception $ex){ - echo $ex->getMessage(); - trigger_error($ex->getMessage(), E_ERROR); - Utils::send500($uri); - } - - } - -} - -?> - diff --git a/classes/modules/serviceModule.php b/classes/modules/serviceModule.php index fc6879c4..b5ea8cd4 100644 --- a/classes/modules/serviceModule.php +++ b/classes/modules/serviceModule.php @@ -66,8 +66,6 @@ class ServiceModule extends abstractModule{ $context = array(); $context['contentType'] = $acceptContentType; $context['endpoints'] = $endpoints; - //$sp = new SpecialFunction(); - //$sp->execute($localUri, $context); $f = $this->getFunction($localUri); $params = array(); $params = $this->getParams($localUri); diff --git a/common.inc.php b/common.inc.php index db988336..b78a9319 100644 --- a/common.inc.php +++ b/common.inc.php @@ -33,7 +33,6 @@ $conf['http_accept']['nt'] = array('text/plain'); $conf['service']['prefix'] = 'services'; -$conf['service']['class'] = 'classes/BasicSpecialFunction.php'; $conf['type']['prefix'] = 'types'; $conf['uri']['prefix'] = 'uris'; -- GitLab