当前位置: 首页>>代码示例>>PHP>>正文


PHP JUri::getScheme方法代码示例

本文整理汇总了PHP中JUri::getScheme方法的典型用法代码示例。如果您正苦于以下问题:PHP JUri::getScheme方法的具体用法?PHP JUri::getScheme怎么用?PHP JUri::getScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUri的用法示例。


在下文中一共展示了JUri::getScheme方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compile

 public function compile()
 {
     $doc = JFactory::getDocument();
     $headers = $doc->getHeadData();
     $javascripts = JArrayHelper::getValue($headers, 'scripts');
     $dest = JPath::clean($this->paths->get('js.compressed'));
     $compile = $this->params->get('minify_js', 1);
     $changed = (bool) $this->isJsUpdated();
     JLog::add('Javascript cache changed: ' . ((bool) $changed ? 'true' : 'false'), JLog::DEBUG, $this->logger);
     $force = (bool) ($compile == 2);
     $changed = (bool) ($compile == 1 && $changed);
     JLog::add('Force Javascript minification: ' . ((bool) $force ? 'true' : 'false'), JLog::DEBUG, $this->logger);
     JLog::add('Minify Javascript: ' . ((bool) $changed ? 'true' : 'false'), JLog::DEBUG, $this->logger);
     $uncompressed = '';
     foreach (array_keys($javascripts) as $script) {
         $url = new JUri($script);
         if (!$url->getScheme()) {
             $url = new JUri(JUri::base());
             $url->setPath($script);
         }
         $key = str_replace(JUri::base(), JPATH_ROOT . '/', (string) $url);
         if (array_search($key, $this->paths->get('js.uncompressed')) !== false) {
             unset($headers['scripts'][$script]);
             if (!JFile::exists($dest) || $changed || $force) {
                 JLog::add('Compressing: ' . $key . ' to ' . $dest, JLog::DEBUG, $this->logger);
                 $stream = new JStream();
                 $stream->open($key);
                 $response = $stream->read($stream->filesize());
                 $stream->close();
                 $uncompressed .= $response;
             }
         }
     }
     if ($uncompressed) {
         file_put_contents($dest, JSMinPlus::minify($uncompressed, $dest));
         $this->updateCache(self::CACHEKEY . '.files.js', $this->paths->get('js.uncompressed'));
     }
     // workaround. There needs to be at least one script.
     if (count($headers['scripts']) == 0) {
         $url = str_replace(JPATH_ROOT . '/', JUri::base(), $dest);
         $headers['scripts'][$url] = array('mime' => 'text/javascript', 'defer' => false, 'async' => false);
     }
     $doc->setHeadData($headers);
 }
开发者ID:Vartacom,项目名称:bootstrapbase,代码行数:44,代码来源:js.php

示例2: parse

 /**
  * Function to convert a route to an internal URI
  *
  * @param   JUri  $uri  The uri.
  *
  * @return  array
  */
 public function parse($uri)
 {
     $vars = array();
     // Get the application
     $app = JApplication::getInstance('site');
     if ($app->getCfg('force_ssl') == 2 && strtolower($uri->getScheme()) != 'https') {
         // Forward to https
         $uri->setScheme('https');
         $app->redirect((string) $uri);
     }
     // Get the path
     // Decode URL to convert punycode to unicode so that strings match when routing.
     $path = urldecode($uri->getPath());
     // Remove the base URI path.
     $path = substr_replace($path, '', 0, strlen(JUri::base(true)));
     // Check to see if a request to a specific entry point has been made.
     if (preg_match("#.*?\\.php#u", $path, $matches)) {
         // Get the current entry point path relative to the site path.
         $scriptPath = realpath($_SERVER['SCRIPT_FILENAME'] ? $_SERVER['SCRIPT_FILENAME'] : str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']));
         $relativeScriptPath = str_replace('\\', '/', str_replace(JPATH_SITE, '', $scriptPath));
         // If a php file has been found in the request path, check to see if it is a valid file.
         // Also verify that it represents the same file from the server variable for entry script.
         if (file_exists(JPATH_SITE . $matches[0]) && $matches[0] == $relativeScriptPath) {
             // Remove the entry point segments from the request path for proper routing.
             $path = str_replace($matches[0], '', $path);
         }
     }
     // Identify format
     if ($this->_mode == JROUTER_MODE_SEF) {
         if ($app->getCfg('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/')) {
             if ($suffix = pathinfo($path, PATHINFO_EXTENSION)) {
                 $vars['format'] = $suffix;
             }
         }
     }
     // Set the route
     $uri->setPath(trim($path, '/'));
     $vars += parent::parse($uri);
     return $vars;
 }
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:47,代码来源:site.php

示例3: connect

 /**
  * Method to connect to a server and get the resource.
  *
  * @param   JUri     $uri      The URI to connect with.
  * @param   integer  $timeout  Read timeout in seconds.
  *
  * @return  resource  Socket connection resource.
  *
  * @since   11.3
  * @throws  RuntimeException
  */
 protected function connect(JUri $uri, $timeout = null)
 {
     $errno = null;
     $err = null;
     // Get the host from the uri.
     $host = $uri->isSsl() ? 'ssl://' . $uri->getHost() : $uri->getHost();
     // If the port is not explicitly set in the URI detect it.
     if (!$uri->getPort()) {
         $port = $uri->getScheme() == 'https' ? 443 : 80;
     } else {
         $port = $uri->getPort();
     }
     // Build the connection key for resource memory caching.
     $key = md5($host . $port);
     // If the connection already exists, use it.
     if (!empty($this->connections[$key]) && is_resource($this->connections[$key])) {
         // Connection reached EOF, cannot be used anymore
         $meta = stream_get_meta_data($this->connections[$key]);
         if ($meta['eof']) {
             if (!fclose($this->connections[$key])) {
                 throw new RuntimeException('Cannot close connection');
             }
         } elseif (!$meta['timed_out']) {
             return $this->connections[$key];
         }
     }
     if (!is_numeric($timeout)) {
         $timeout = ini_get('default_socket_timeout');
     }
     // Capture PHP errors
     $php_errormsg = '';
     $track_errors = ini_get('track_errors');
     ini_set('track_errors', true);
     // PHP sends a warning if the uri does not exists; we silence it and throw an exception instead.
     // Attempt to connect to the server
     $connection = @fsockopen($host, $port, $errno, $err, $timeout);
     if (!$connection) {
         if (!$php_errormsg) {
             // Error but nothing from php? Create our own
             $php_errormsg = sprintf('Could not connect to resource: %s', $uri, $err, $errno);
         }
         // Restore error tracking to give control to the exception handler
         ini_set('track_errors', $track_errors);
         throw new RuntimeException($php_errormsg);
     }
     // Restore error tracking to what it was before.
     ini_set('track_errors', $track_errors);
     // Since the connection was successful let's store it in case we need to use it later.
     $this->connections[$key] = $connection;
     // If an explicit timeout is set, set it.
     if (isset($timeout)) {
         stream_set_timeout($this->connections[$key], (int) $timeout);
     }
     return $this->connections[$key];
 }
开发者ID:grlf,项目名称:eyedock,代码行数:66,代码来源:socket.php

示例4: _connect

 /**
  * Method to connect to a server and get the resource.
  *
  * @param   JUri   $uri  The URI to connect with.
  *
  * @return  mixed  Connection resource on success or boolean false on failure.
  *
  * @since   11.1
  */
 protected function _connect(JUri $uri)
 {
     // Initialize variables.
     $errno = null;
     $err = null;
     // Get the host from the uri.
     $host = $uri->isSSL() ? 'ssl://' . $uri->getHost() : $uri->getHost();
     // If the port is not explicitly set in the URI detect it.
     if (!$uri->getPort()) {
         $port = $uri->getScheme() == 'https' ? 443 : 80;
     } else {
         $port = $uri->getPort();
     }
     // Build the connection key for resource memory caching.
     $key = md5($host . $port);
     // If the connection already exists, use it.
     if (!empty($this->_connections[$key]) && is_resource($this->_connections[$key])) {
         // Make sure the connection has not timed out.
         $meta = stream_get_meta_data($this->_connections[$key]);
         if (!$meta['timed_out']) {
             return $this->_connections[$key];
         }
     }
     // Attempt to connect to the server.
     if ($this->_connections[$key] = fsockopen($host, $port, $errno, $err, $this->_timeout)) {
         stream_set_timeout($this->_connections[$key], $this->_timeout);
     }
     return $this->_connections[$key];
 }
开发者ID:carmerin,项目名称:cesae-web,代码行数:38,代码来源:http.php

示例5: connect

 /**
  * Method to connect to a server and get the resource.
  *
  * @param   JUri     $uri      The URI to connect with.
  * @param   integer  $timeout  Read timeout in seconds.
  *
  * @return  resource  Socket connection resource.
  *
  * @since   11.3
  * @throws  RuntimeException
  */
 protected function connect(JUri $uri, $timeout = null)
 {
     // Initialize variables.
     $errno = null;
     $err = null;
     // Get the host from the uri.
     $host = $uri->isSSL() ? 'ssl://' . $uri->getHost() : $uri->getHost();
     // If the port is not explicitly set in the URI detect it.
     if (!$uri->getPort()) {
         $port = $uri->getScheme() == 'https' ? 443 : 80;
     } else {
         $port = $uri->getPort();
     }
     // Build the connection key for resource memory caching.
     $key = md5($host . $port);
     // If the connection already exists, use it.
     if (!empty($this->connections[$key]) && is_resource($this->connections[$key])) {
         // Connection reached EOF, cannot be used anymore
         $meta = stream_get_meta_data($this->connections[$key]);
         if ($meta['eof']) {
             if (!fclose($this->connections[$key])) {
                 throw new RuntimeException('Cannot close connection');
             }
         } elseif (!$meta['timed_out']) {
             return $this->connections[$key];
         }
     }
     if (!is_numeric($timeout)) {
         $timeout = ini_get("default_socket_timeout");
     }
     // Attempt to connect to the server.
     $connection = fsockopen($host, $port, $errno, $err, $timeout);
     if (!$connection) {
         throw new RuntimeException($err, $errno);
     }
     // Since the connection was successful let's store it in case we need to use it later.
     $this->connections[$key] = $connection;
     // If an explicit timeout is set, set it.
     if (isset($timeout)) {
         stream_set_timeout($this->connections[$key], (int) $timeout);
     }
     return $this->connections[$key];
 }
开发者ID:exntu,项目名称:joomla-cms,代码行数:54,代码来源:socket.php

示例6: request


//.........这里部分代码省略.........
     // Don't wait for body when $method is HEAD
     $options[CURLOPT_NOBODY] = $method === 'HEAD';
     // Initialize the certificate store
     $options[CURLOPT_CAINFO] = $this->options->get('curl.certpath', __DIR__ . '/cacert.pem');
     // If data exists let's encode it and make sure our Content-type header is set.
     if (isset($data)) {
         // If the data is a scalar value simply add it to the cURL post fields.
         if (is_scalar($data) || isset($headers['Content-Type']) && strpos($headers['Content-Type'], 'multipart/form-data') === 0) {
             $options[CURLOPT_POSTFIELDS] = $data;
         } else {
             $options[CURLOPT_POSTFIELDS] = http_build_query($data);
         }
         if (!isset($headers['Content-Type'])) {
             $headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8';
         }
         // Add the relevant headers.
         if (is_scalar($options[CURLOPT_POSTFIELDS])) {
             $headers['Content-Length'] = strlen($options[CURLOPT_POSTFIELDS]);
         }
     }
     // Build the headers string for the request.
     $headerArray = array();
     if (isset($headers)) {
         foreach ($headers as $key => $value) {
             $headerArray[] = $key . ': ' . $value;
         }
         // Add the headers string into the stream context options array.
         $options[CURLOPT_HTTPHEADER] = $headerArray;
     }
     // Curl needs the accepted encoding header as option
     if (isset($headers['Accept-Encoding'])) {
         $options[CURLOPT_ENCODING] = $headers['Accept-Encoding'];
     }
     // If an explicit timeout is given user it.
     if (isset($timeout)) {
         $options[CURLOPT_TIMEOUT] = (int) $timeout;
         $options[CURLOPT_CONNECTTIMEOUT] = (int) $timeout;
     }
     // If an explicit user agent is given use it.
     if (isset($userAgent)) {
         $options[CURLOPT_USERAGENT] = $userAgent;
     }
     // Set the request URL.
     $options[CURLOPT_URL] = (string) $uri;
     // We want our headers. :-)
     $options[CURLOPT_HEADER] = true;
     // Return it... echoing it would be tacky.
     $options[CURLOPT_RETURNTRANSFER] = true;
     // Override the Expect header to prevent cURL from confusing itself in its own stupidity.
     // Link: http://the-stickman.com/web-development/php-and-curl-disabling-100-continue-header/
     $options[CURLOPT_HTTPHEADER][] = 'Expect:';
     // Follow redirects if server config allows
     if ($this->redirectsAllowed()) {
         $options[CURLOPT_FOLLOWLOCATION] = (bool) $this->options->get('follow_location', true);
     }
     // Proxy configuration
     $config = JFactory::getConfig();
     if ($config->get('proxy_enable')) {
         $options[CURLOPT_PROXY] = $config->get('proxy_host') . ':' . $config->get('proxy_port');
         if ($user = $config->get('proxy_user')) {
             $options[CURLOPT_PROXYUSERPWD] = $user . ':' . $config->get('proxy_pass');
         }
     }
     // Set any custom transport options
     foreach ($this->options->get('transport.curl', array()) as $key => $value) {
         $options[$key] = $value;
     }
     // Authentification, if needed
     if ($this->options->get('userauth') && $this->options->get('passwordauth')) {
         $options[CURLOPT_USERPWD] = $this->options->get('userauth') . ':' . $this->options->get('passwordauth');
         $options[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
     }
     // Set the cURL options.
     curl_setopt_array($ch, $options);
     // Execute the request and close the connection.
     $content = curl_exec($ch);
     // Check if the content is a string. If it is not, it must be an error.
     if (!is_string($content)) {
         $message = curl_error($ch);
         if (empty($message)) {
             // Error but nothing from cURL? Create our own
             $message = 'No HTTP response received';
         }
         throw new RuntimeException($message);
     }
     // Get the request information.
     $info = curl_getinfo($ch);
     // Close the connection.
     curl_close($ch);
     $response = $this->getResponse($content, $info);
     // Manually follow redirects if server doesn't allow to follow location using curl
     if ($response->code >= 301 && $response->code < 400 && isset($response->headers['Location'])) {
         $redirect_uri = new JUri($response->headers['Location']);
         if (in_array($redirect_uri->getScheme(), array('file', 'scp'))) {
             throw new RuntimeException('Curl redirect cannot be used in file or scp requests.');
         }
         $response = $this->request($method, $redirect_uri, $data, $headers, $timeout, $userAgent);
     }
     return $response;
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:101,代码来源:curl.php

示例7: findFile

 /**
  * Find the file we want in oaths.
  *
  * @param   string  $file  File name to find.
  * @param   string  $type  File type, css or js.
  * @param   string  $name  The instance name.
  *
  * @return  array|boolean  Found file & sum information.
  */
 protected function findFile($file, $type, $name = null)
 {
     $name = $name ?: $this->name;
     $foundpath = '';
     $sum = '';
     $uri = new \JUri($file);
     if ($uri->getScheme()) {
         return $file;
     }
     foreach (clone $this->paths as $path) {
         $path = str_replace(array('{name}', '{type}'), array($name, $type), $path);
         $path = trim($path, '/');
         // Get compressed file
         if ($foundFile = $this->getMinFile(JPATH_ROOT . '/' . $path, $file)) {
             $file = $foundFile;
             $foundpath = $path;
             break;
         }
         $filepath = $path . '/' . $file;
         if (is_file(JPATH_ROOT . '/' . $filepath)) {
             $foundpath = $path;
             break;
         }
     }
     if (!$foundpath) {
         return false;
     }
     $foundpath = str_replace(array('/', '\\'), '/', $foundpath);
     // Get SUM
     if (!$this->debug) {
         $sumfile = JPATH_ROOT . '/' . $foundpath . '/' . $file . '.sum';
         if (!is_file($sumfile)) {
             $sumfile = JPATH_ROOT . '/' . $foundpath . '/' . $this->sumName;
         }
         if (is_file($sumfile)) {
             $sum = file_get_contents($sumfile);
         }
         if ($sum) {
             $sum = str_replace(array("\n", "\r"), '', $sum);
             $sum = addslashes(htmlentities($sum));
         }
     } else {
         $sum = null;
     }
     // Build path
     $file = $foundpath . '/' . $file;
     return array('file' => $file, 'sum' => $sum);
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:57,代码来源:AssetManager.php

示例8: testSetScheme

 /**
  * Test the setScheme method.
  *
  * @return  void
  *
  * @since   11.1
  * @covers  JUri::setScheme
  */
 public function testSetScheme()
 {
     $this->object->setScheme('ftp');
     $this->assertThat($this->object->getScheme(), $this->equalTo('ftp'));
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:13,代码来源:JURITest.php

示例9: onAfterInitialise

 function onAfterInitialise()
 {
     /** @var JSite $app */
     $app = JFactory::getApplication();
     if ($app->isAdmin()) {
         // don't use MobileJoomla in backend
         return;
     }
     $is_joomla15 = $this->isJoomla15();
     //load MobileJoomla class
     require_once JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/classes/mobilejoomla.php';
     //load config
     $MobileJoomla_Settings =& MobileJoomla::getConfig();
     $MobileJoomla_Device =& MobileJoomla::getDevice();
     // check for legacy redirect
     if (@$_GET['option'] == 'com_mobilejoomla' && @$_GET['task'] == 'setmarkup' && isset($_GET['markup']) && isset($_GET['return'])) {
         $desktop_uri = new JUri($MobileJoomla_Settings['desktop_url']);
         $uri = new JUri(base64_decode($_GET['return']));
         if (!$uri->getScheme()) {
             $uri->setScheme('http');
         }
         $uri->setHost($desktop_uri->getHost());
         $uri->setPort($desktop_uri->getPort());
         $app->redirect($uri->toString());
     }
     JPluginHelper::importPlugin('mobile');
     $cached_data = $app->getUserState('mobilejoomla.cache');
     if ($cached_data !== null) {
         $cached_data = @gzinflate(@base64_decode($cached_data));
         if ($cached_data !== false) {
             $cached_data = @unserialize($cached_data);
         }
     }
     if (is_array($cached_data)) {
         $MobileJoomla_Device = $cached_data['device'];
     } else {
         $app->triggerEvent('onDeviceDetection', array(&$MobileJoomla_Settings, &$MobileJoomla_Device));
         $gzlevel = 5;
         $cached_data = array('device' => $MobileJoomla_Device);
         $cached_data = base64_encode(gzdeflate(serialize($cached_data), $gzlevel));
         $app->setUserState('mobilejoomla.cache', $cached_data);
     }
     $MobileJoomla_Device['markup'] = self::CheckMarkup($MobileJoomla_Device['markup']);
     $MobileJoomla_Device['real_markup'] = $MobileJoomla_Device['markup'];
     $app->triggerEvent('onAfterDeviceDetection', array(&$MobileJoomla_Settings, &$MobileJoomla_Device));
     $MobileJoomla_Device['markup'] = self::CheckMarkup($MobileJoomla_Device['markup']);
     $markup = $MobileJoomla_Device['markup'];
     $MobileJoomla_Device['default_markup'] = $markup;
     //get user choice
     $user_markup = $this->getUserMarkup();
     if ($user_markup !== false) {
         $markup = $user_markup;
     }
     // template preview
     $getTemplate = isset($_GET['template']) ? $_GET['template'] : null;
     if (version_compare(JVERSION, '1.7', '>=')) {
         if ($getTemplate === null && isset($_GET['templateStyle']) && is_int($_GET['templateStyle'])) {
             $db = JFactory::getDBO();
             $query = 'SELECT template FROM #__template_styles WHERE id = ' . intval($_GET['templateStyle']) . ' AND client_id = 0';
             $db->setQuery($query);
             $getTemplate = $db->loadResult();
         }
     } elseif (version_compare(JVERSION, '1.6', '>=')) {
         if (is_int($getTemplate)) {
             $db = JFactory::getDBO();
             $query = 'SELECT template FROM #__template_styles WHERE id = ' . intval($getTemplate) . ' AND client_id = 0';
             $db->setQuery($query);
             $getTemplate = $db->loadResult();
         }
     }
     if ($getTemplate) {
         switch ($getTemplate) {
             case $MobileJoomla_Settings['xhtml.template']:
                 $markup = 'xhtml';
                 break;
             case $MobileJoomla_Settings['iphone.template']:
                 $markup = 'iphone';
                 break;
             case $MobileJoomla_Settings['wml.template']:
                 $markup = 'wml';
                 break;
             case $MobileJoomla_Settings['chtml.template']:
                 $markup = 'chtml';
                 break;
         }
     }
     $MobileJoomla_Device['markup'] = $markup;
     if ($MobileJoomla_Device['screenwidth'] == 0 || $MobileJoomla_Device['screenheight'] == 0) {
         switch ($markup) {
             case 'wml':
                 $MobileJoomla_Device['screenwidth'] = 64;
                 $MobileJoomla_Device['screenheight'] = 96;
                 break;
             case 'chtml':
                 $MobileJoomla_Device['screenwidth'] = 120;
                 $MobileJoomla_Device['screenheight'] = 128;
                 break;
             case 'xhtml':
                 $MobileJoomla_Device['screenwidth'] = 320;
                 $MobileJoomla_Device['screenheight'] = 480;
//.........这里部分代码省略.........
开发者ID:bright-spark,项目名称:mobilejoomla,代码行数:101,代码来源:mobilebot.php

示例10: discover

 /**
  * Recursively discovers the atom/rss OpenSearch url.
  *
  * @param   string     $sourceUrl  The url to discover.
  *
  * @return  JRegistry  A OpenSearch description as a JRegistry or false if no description
  * can be found.
  */
 private function discover($sourceUrl)
 {
     $discovered = false;
     $url = new JUri($sourceUrl);
     $http = JHttpFactory::getHttp();
     $response = $http->get($url);
     if ((int) $response->code === 200) {
         $contentType = JArrayHelper::getValue($response->headers, 'Content-Type');
         $contentType = $this->parseContentType($contentType);
         if ($contentType === 'text/html') {
             $dom = new DomDocument();
             $dom->loadHTML($response->body);
             $xpath = new DOMXPath($dom);
             $opendocument = '//html/head/link[@type="application/opensearchdescription+xml"]';
             $links = $xpath->query($opendocument);
             if (count($links)) {
                 $link = $dom->importNode($links->item(0), true);
                 $href = new JUri($link->getAttribute('href'));
                 // sometimes the opensearch url is not complete so complete it.
                 if (!$href->getScheme()) {
                     $url->setQuery(array());
                     $url->setPath($href);
                     $url->setQuery($href->getQuery());
                 }
                 $url->setVar('source', $sourceUrl);
                 $discovered = $this->discover((string) $url);
             }
         } else {
             if ($contentType === 'application/opensearchdescription+xml') {
                 $originalUrl = $url->getVar('source');
                 $xml = new SimpleXMLElement($response->body);
                 if (isset($xml->Url)) {
                     $urls = $xml->Url;
                     $i = 0;
                     while (($url = $urls[$i]) && !$discovered) {
                         $template = JArrayHelper::getValue($url, 'template', null, 'string');
                         $type = JArrayHelper::getValue($url, 'type', null, 'string');
                         $link = new JUri($template);
                         $queries = $link->getQuery(true);
                         //@todo a search/replace will probably suffice.
                         foreach ($queries as $keyq => &$valueq) {
                             if ($valueq === "{searchTerms}") {
                                 $queries[$keyq] = JUri::getInstance($originalUrl)->getVar($keyq);
                                 break;
                             }
                         }
                         $link->setQuery($queries);
                         // don't try and discover the html search.
                         if (strpos($type, 'text/html') === false) {
                             $discovered = $this->discover((string) $link);
                         }
                         $i++;
                     }
                 }
             } else {
                 if (array_search($contentType, array('application/xml', 'text/xml', 'application/atom+xml', 'application/rss+xml')) !== false) {
                     //@todo JUri not updating url via setVar. May need more testing.
                     $discovered = new JRegistry();
                     $discovered->set('discovery.type', 'opensearch');
                     $discovered->set('discovery.url', (string) $sourceUrl);
                     $discovered->set('discovery.plugin.type', (string) $contentType);
                 }
             }
         }
     }
     return $discovered;
 }
开发者ID:knowledgearcdotorg,项目名称:jharvest,代码行数:75,代码来源:opensearch.php

示例11: connect

 /**
  * Method to connect to a server and get the resource.
  *
  * @param   JUri     $uri      The URI to connect with.
  * @param   integer  $timeout  Read timeout in seconds.
  *
  * @return  resource  Socket connection resource.
  *
  * @since   11.3
  * @throws  JMapExceptionRuntime
  */
 protected function connect(JUri $uri, $timeout = null)
 {
     // Initialize variables.
     $errno = null;
     $err = null;
     // Get the host from the uri.
     $host = $uri->isSSL() ? 'ssl://' . $uri->getHost() : $uri->getHost();
     // If the port is not explicitly set in the URI detect it.
     if (!$uri->getPort()) {
         $port = $uri->getScheme() == 'https' ? 443 : 80;
     } else {
         $port = $uri->getPort();
     }
     // Build the connection key for resource memory caching.
     $key = md5($host . $port);
     // If the connection already exists, use it.
     if (!empty($this->connections[$key]) && is_resource($this->connections[$key])) {
         // Make sure the connection has not timed out.
         $meta = stream_get_meta_data($this->connections[$key]);
         if (!$meta['timed_out']) {
             return $this->connections[$key];
         }
     }
     // Attempt to connect to the server.
     $connection = @fsockopen($host, $port, $errno, $err, $timeout);
     if (!$connection) {
         throw new JMapExceptionRuntime($err, 'error', $errno);
     }
     // Since the connection was successful let's store it in case we need to use it later.
     $this->connections[$key] = $connection;
     // If an explicit timeout is set, set it.
     if (isset($timeout)) {
         stream_set_timeout($this->connections[$key], (int) $timeout);
     }
     return $this->connections[$key];
 }
开发者ID:neoandrew1000,项目名称:crao_journal,代码行数:47,代码来源:socket.php


注:本文中的JUri::getScheme方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。