/** * Create a new XML cURL API call instance * * @param string $url URL to send the request to * @param array $curl_opts Array of additional cURL options to set * @param array $headers Array of headers to set in addition to defaults */ public function __construct($url = null, array $curl_opts = array(), array $headers = array()) { parent::__construct($this::VERSION, $this::ENCODING, $this::ROOT_EL, $this::XMLNS); $this->curlInit($url); $this->headers['Accept'] = join(',', $this->accept); $headers = array_merge($this->headers, $headers); $this->curlSetOptArray($this->default_opts); $this->curlSetOpt(CURLOPT_HTTPHEADER, array_map(function ($key, $value) { return "{$key}: {$value}"; }, array_keys($headers), array_values($headers))); $this->curlSetOptArray($curl_opts); }
/** * Creates a new OpenSearch instance * * @param string $name Name of the search plugin * @param string $description Short description * @param [type] $image Icon to use * @param string $url URL to submit queries to */ public function __construct($name = '', $description = '', $image = self::ICON, $url = '') { parent::__construct(self::VERSION, self::ENCODING, self::ROOT_EL, self::OPENSEARCH_NS); $this->getPathInfo($image); if (!@file_exists($this->absolute_path)) { $this->getPathInfo(self::ICON); } $this->absolute_path = '/' . preg_replace('/^' . preg_quote(str_replace(DIRECTORY_SEPARATOR, '/', $_SERVER['DOCUMENT_ROOT']), '/') . '/', null, $this->absolute_path); $this->URL = $this->parseURL($url)->URLToString(['scheme', 'host']); list($a, $b, $c, $this->image_x, $this->image_y, $this->image_type) = array_values(getimagesize($image)); unset($a, $b, $c); if ($this->image_type === 'image/vnd.microsoft.icon') { $this->image_type = 'image/x-icon'; } $this->name = $name; $this->description = $description; $this->image = $this->URLToString(['scheme', 'host']) . $this->absolute_path; }