Exemple #1
0
 public static function simpleErrorAsXML($code)
 {
     $xml = new SimpleXMLElement(SmintapiConfig::getXMLrootElement());
     $message = self::getErrorMessage($code);
     $error = $xml->addChild("error", $message);
     $error->addAttribute("code", $code);
     return $xml;
 }
Exemple #2
0
 private static function singleton()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c("Please use initConfig(..) before this call.");
     }
     return self::$instance;
 }
Exemple #3
0
 public function __construct($url, $arguments, $accept)
 {
     $this->response = new ResponseObject();
     $this->response->setStatus = 500;
     // set error code to be overwritten in implementations
     $this->apiConfig = SmintapiConfig::getConfig();
     $this->url = $url;
     $this->arguments = $arguments;
     $this->accept = $accept;
     $this->dbconnection = SmintapiConfig::getDBConnection();
 }
Exemple #4
0
 public static function simpleXMLElement()
 {
     return new SimpleXMLElement(SmintapiConfig::getXMLrootElement());
 }
Exemple #5
0
<?php

// I expect $CONFIGFILENAME to be set, otherwise bail out
if (isset($CONFIGFILENAME)) {
    $apiConfig = SmintapiConfig::initConfig($CONFIGFILENAME);
    $apiConfig = SmintapiConfig::getConfig();
} else {
    throw new Exception('Please set $CONFIGFILENAME to the config file to be used.');
}
// init logger with log level defined in the config file
$mylog = MyLog::singleton($apiConfig["logging"]["logLevel"]);
// define the autoloader to load classes from the lib folder
function __autoload($className)
{
    $filename = dirname(__FILE__) . '/../lib/' . $className . '.php';
    if (file_exists($filename)) {
        require $filename;
    } else {
        throw new Exception('Class "' . $className . '" could not be autoloaded. File not found: ' . $filename);
    }
}
function stripslashes_deep($value)
{
    $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
    return $value;
}