Overview

Namespaces

  • cli_db
    • propel
      • map
      • om
  • cli_import
  • LoggedPDO
  • None
  • PHP
  • webservices
    • cart
    • combisearch
    • details
      • annotations
        • feature
    • graphs
      • barplot
      • genome
    • listing
    • queue

Classes

  • Console_CommandLine_Action_ExtendedHelp
  • LightOpenID
  • Log_firebugJSON
  • WebService

Interfaces

  • CLI_Command

Functions

  • acquire_database
  • cli_error_handler
  • connect_queue_db
  • create_job
  • display_feature
  • display_feature_by_id
  • display_isoform_by_id
  • display_unigene_by_id
  • download
  • execute_command
  • execute_job
  • execute_query_dir
  • get_db_connection
  • get_job_results
  • get_program_databases
  • myErrorHandler
  • pdo_connect
  • report_results_cleanup
  • requestVal
  • smarty_function_call_webservice
  • smarty_function_dbxreflink
  • smarty_function_interprolink
  • smarty_function_publink
  • smarty_modifier_clean_id
  • split_fasta
  • unzip
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: require_once 'TranscriptDB/db.php';
 4: 
 5: /**
 6:  * Abstract Base class for all web services.
 7:  */
 8: abstract class WebService {
 9: 
10:     /**
11:      * Executes the web service.
12:      * @param Array $data User-specified parameters. Usually, url parameters are included as $data[query1], $data[query2],... and $_GET and _POST are merged in
13:      */
14:     abstract public function execute($data);
15: 
16:     /**
17:      * ouputs $dataArray as (on php>=5.4 pretty) JSON
18:      * @param Array $dataArray
19:      */
20:     public static function output($dataArray) {
21:         echo json_encode($dataArray, defined('JSON_PRETTY_PRINT')?JSON_PRETTY_PRINT:0);
22:     }
23: 
24:     /**
25:      * factory method for all web services
26:      * creates an instance of the class called by querystring. additional parameters are returned in $parameters as query1, query2, etc.
27:      * e.g. 
28:      * <code>
29:      * WebService::factory('details/isoform/12345');
30:      * // => 
31:      * return array(new \webservices\details\Isoform(), array('query1'=>'12345'));
32:      * </code>
33:      * @param String $servicePath
34:      * @return list($instance, $parameters)
35:      */
36:     public static function factory($servicePath) {
37:         $serviceBasePath = __DIR__ . DIRECTORY_SEPARATOR . 'webservices';
38: 
39:         $path = explode('/', $servicePath);
40:         $filepath = $serviceBasePath . DIRECTORY_SEPARATOR . $path[0];
41:         $serviceNamespace = '\\webservices\\' . $path[0];
42:         $args = array();
43:         for ($i = 1; $i < count($path); $i++) {
44:             $classname = ucfirst($path[$i]);
45:             $filename = $filepath . DIRECTORY_SEPARATOR . $classname . '.php';
46:             if (file_exists($filename)) {
47:                 for ($j = $i + 1; $j < count($path); $j++) {
48:                     $args['query' . ($j - $i)] = $path[$j];
49:                 }
50:                 break;
51:             }
52:             $filepath .= DIRECTORY_SEPARATOR . strtolower($path[$i]);
53:             $serviceNamespace .= '\\' . strtolower($path[$i]);
54:         }
55: 
56:         //case: no service file found
57:         if (!isset($filename) || !file_exists($filename)) {
58:             return array(null, null);
59:         }
60:         //case: service path tries to escape from basePath
61:         if (!(strpos(realpath($filename), realpath($serviceBasePath)) === 0)) {
62:             return array(null, null);
63:         }
64:         require_once $filename;
65:         //case: file does not contain web service class        
66:         $class = $serviceNamespace . '\\' . $classname;
67:         if (!class_exists($class)) {
68:             return array(null, null);
69:         }
70: 
71:         return array(new $class, $args);
72:     }
73: 
74: 
75: }
76: 
77: ?>
78: 
tbro API documentation generated by ApiGen 2.8.0