Public Member Functions | |
| __construct () | |
| Constructor. | |
| getResources ($a_econtent_id=0) | |
| Get resources from ECS server. | |
| addResource ($a_post) | |
| Add resource. | |
| updateResource ($a_econtent_id, $a_post_string) | |
| update resource | |
| deleteResource ($a_econtent_id) | |
| Delete resource. | |
Protected Attributes | |
| $path_postfix = '' | |
| $settings | |
Private Member Functions | |
| prepareConnection () | |
| prepare connection | |
| call () | |
| call peer | |
Definition at line 38 of file class.ilECSConnector.php.
| ilECSConnector::__construct | ( | ) |
Constructor.
public
Definition at line 51 of file class.ilECSConnector.php.
References ilECSSettings::_getInstance().
{
$this->settings = ilECSSettings::_getInstance();
}
Here is the call graph for this function:| ilECSConnector::addResource | ( | $ | a_post | ) |
Add resource.
public
| string | post data |
| ECSConnectorException |
Definition at line 96 of file class.ilECSConnector.php.
References $res, call(), and prepareConnection().
{
$this->path_postfix = '/econtents';
try
{
$this->prepareConnection();
$this->curl->setOpt(CURLOPT_POST,true);
$this->curl->setOpt(CURLOPT_POSTFIELDS,$a_post);
$res = $this->call();
return new ilECSResult($res);
}
catch(ilCurlConnectionException $exc)
{
throw new ilECSConnectorException('Error calling ECS service: '.$exc->getMessage());
}
}
Here is the call graph for this function:| ilECSConnector::call | ( | ) | [private] |
call peer
private
| ilCurlConnectionException |
Definition at line 235 of file class.ilECSConnector.php.
References $res.
Referenced by addResource(), deleteResource(), getResources(), and updateResource().
{
try
{
$res = $this->curl->exec();
return $res;
}
catch(ilCurlConnectionException $exc)
{
throw($exc);
}
}
Here is the caller graph for this function:| ilECSConnector::deleteResource | ( | $ | a_econtent_id | ) |
Delete resource.
public
| string | econtent id |
| ECSConnectorException |
Definition at line 169 of file class.ilECSConnector.php.
References $res, call(), and prepareConnection().
{
$this->path_postfix = '/econtents';
if($a_econtent_id)
{
$this->path_postfix .= ('/'.(int) $a_econtent_id);
}
else
{
throw new ilECSConnectorException('Error calling deleteResource: No content id given.');
}
try
{
$this->prepareConnection();
$this->curl->setOpt(CURLOPT_CUSTOMREQUEST,'DELETE');
$res = $this->call();
return new ilECSResult($res);
}
catch(ilCurlConnectionException $exc)
{
throw new ilECSConnectorException('Error calling ECS service: '.$exc->getMessage());
}
}
Here is the call graph for this function:| ilECSConnector::getResources | ( | $ | a_econtent_id = 0 |
) |
Get resources from ECS server.
public
| int | e-content id |
| ECSConnectorException |
Definition at line 67 of file class.ilECSConnector.php.
References $res, call(), and prepareConnection().
{
$this->path_postfix = '/econtents';
if($a_econtent_id)
{
$this->path_postfix .= ('/'.(int) $a_econtent_id);
}
try
{
$this->prepareConnection();
$res = $this->call();
return new ilECSResult($res);
}
catch(ilCurlConnectionException $exc)
{
throw new ilECSConnectorException('Error calling ECS service: '.$exc->getMessage());
}
}
Here is the call graph for this function:| ilECSConnector::prepareConnection | ( | ) | [private] |
prepare connection
private
| ilCurlConnectionException |
Definition at line 203 of file class.ilECSConnector.php.
References ilECSSettings::PROTOCOL_HTTPS.
Referenced by addResource(), deleteResource(), getResources(), and updateResource().
{
try
{
$this->curl = new ilCurlConnection($this->settings->getServerURI().$this->path_postfix);
$this->curl->init();
if($this->settings->getProtocol() == ilECSSettings::PROTOCOL_HTTPS)
{
$this->curl->setOpt(CURLOPT_HTTPHEADER,array(0 => 'Accept: application/json'));
$this->curl->setOpt(CURLOPT_SSL_VERIFYPEER,0);
$this->curl->setOpt(CURLOPT_SSL_VERIFYHOST,1);
$this->curl->setOpt(CURLOPT_VERBOSE,1);
$this->curl->setOpt(CURLOPT_RETURNTRANSFER,true);
$this->curl->setOpt(CURLE_SSL_PEER_CERTIFICATE,$this->settings->getCACertPath());
$this->curl->setOpt(CURLOPT_SSLCERT,$this->settings->getClientCertPath());
$this->curl->setOpt(CURLOPT_SSLKEY,$this->settings->getKeyPath());
$this->curl->setOpt(CURLOPT_SSLKEYPASSWD,$this->settings->getKeyPassword());
}
}
catch(ilCurlConnectionException $exc)
{
throw($exc);
}
}
Here is the caller graph for this function:| ilECSConnector::updateResource | ( | $ | a_econtent_id, | |
| $ | a_post_string | |||
| ) |
update resource
public
| int | econtent id | |
| string | post content |
| ECSConnectorException |
Definition at line 123 of file class.ilECSConnector.php.
References $res, call(), and prepareConnection().
{
$this->path_postfix = '/econtents';
if($a_econtent_id)
{
$this->path_postfix .= ('/'.(int) $a_econtent_id);
}
else
{
throw new ilECSConnectorException('Error calling updateResource: No content id given.');
}
try
{
$this->prepareConnection();
$this->curl->setOpt(CURLOPT_PUT,true);
$fp = fopen('ecs_content.txt','w');
fwrite($fp,$a_post_string);
fclose($fp);
#$this->curl->setOpt(CURLOPT_POSTFIELDS,$a_post_string);
$this->curl->setOpt(CURLOPT_UPLOAD,true);
$this->curl->setOpt(CURLOPT_INFILESIZE,filesize('ecs_content.txt'));
$fp = fopen('ecs_content.txt','r');
$this->curl->setOpt(CURLOPT_INFILE,$fp);
#fclose($fp);
$res = $this->call();
return new ilECSResult($res);
}
catch(ilCurlConnectionException $exc)
{
throw new ilECSConnectorException('Error calling ECS service: '.$exc->getMessage());
}
}
Here is the call graph for this function:ilECSConnector::$path_postfix = '' [protected] |
Definition at line 40 of file class.ilECSConnector.php.
ilECSConnector::$settings [protected] |
Definition at line 42 of file class.ilECSConnector.php.
1.7.1