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


PHP JUri::setPath方法代码示例

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


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

示例1: getMember

 protected function getMember($member, $realm, array $fields = array('items', 'achievements'))
 {
     $uri = new JUri();
     $uri->setPath('/wow/character/' . $realm . '/' . $member);
     $uri->setVar('fields', implode(',', $fields));
     return $this->getRemote($uri);
 }
开发者ID:b2un0,项目名称:joomla-plugin-system-wow,代码行数:7,代码来源:wowapi.php

示例2: getBattleNetUrl

 public function getBattleNetUrl()
 {
     $uri = new JUri();
     $uri->setScheme($this->params->get('scheme', 'http'));
     $uri->setHost($this->params->get('region') . '.battle.net');
     $uri->setPath('/wow/' . $this->params->get('locale') . '/guild/' . rawurlencode($this->params->get('realm')) . '/' . rawurlencode($this->params->get('guild')) . '/');
     return $uri->toString();
 }
开发者ID:b2un0,项目名称:joomla-plugin-system-wow,代码行数:8,代码来源:WoW.php

示例3: getData

 /**
  * @see https://www.warcraftlogs.com/v1/docs#!/Reports/
  * @throws RuntimeException
  *
  * @return stdClass
  */
 public function getData($api_key)
 {
     $uri = new JUri();
     $this->params->set('realm', str_replace("'", '', $this->params->get('realm')));
     $this->params->set('guild', str_replace(' ', '+', $this->params->get('guild')));
     $uri->setPath('/v1/reports/guild/' . $this->params->get('guild') . '/' . JApplicationHelper::stringURLSafe($this->params->get('realm')) . '/' . $this->params->get('region'));
     $uri->setVar('api_key', $api_key);
     return $this->getRemote($uri);
 }
开发者ID:b2un0,项目名称:joomla-plugin-system-wow,代码行数:15,代码来源:warcraftlogs.php

示例4: _

 /**
  * Build by resource.
  *
  * @param   string   $resource The resource key to find our route.
  * @param   array    $data     The url query data.
  * @param   boolean  $xhtml    Replace & by & for XML compilance.
  * @param   integer  $ssl      Secure state for the resolved URI.
  *                             1: Make URI secure using global secure site URI.
  *                             2: Make URI unsecure using the global unsecure site URI.
  *
  * @return  string Route url.
  */
 public static function _($resource, $data = array(), $xhtml = true, $ssl = null)
 {
     $resource = explode('.', $resource, 2);
     if (count($resource) == 2) {
         $data['option'] = $resource[0];
         $data['_resource'] = $resource[1];
     } elseif (count($resource) == 1) {
         $data['option'] = $resource[0];
         $data['_resource'] = null;
     }
     $url = new \JUri();
     $url->setQuery($data);
     $url->setPath('index.php');
     return \JRoute::_((string) $url, $xhtml, $ssl);
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:27,代码来源:Route.php

示例5: 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

示例6: gTranslate

 /**
  * A method to do Google translate.
  *
  * @param   string $text      String to translate.
  * @param   string $SourceLan Translate from this language, eg: 'zh-tw'. Empty will auto detect.
  * @param   string $ResultLan Translate to this language, eg: 'en'. Empty will auto detect.
  *
  * @return  string|bool Translated text.
  */
 public static function gTranslate($text, $SourceLan, $ResultLan)
 {
     $url = new \JUri();
     // For Google APIv2
     $url->setHost('https://www.googleapis.com/');
     $url->setPath('language/translate/v2');
     $query['key'] = self::APT_KEY;
     $query['q'] = urlencode($text);
     $query['source'] = $SourceLan;
     $query['target'] = $ResultLan;
     if (!$text) {
         return false;
     }
     $url->setQuery($query);
     $url->toString();
     $response = CurlHelper::get((string) $url);
     if (empty($response->body)) {
         return '';
     }
     $json = new \JRegistry();
     $json->loadString($response->body, 'json');
     $r = $json->get('data.translations');
     return $r[0]->translatedText;
 }
开发者ID:beingsane,项目名称:quickcontent,代码行数:33,代码来源:LanguageHelper.php

示例7: testSetPath

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

示例8: _buildSefRoute

 /**
  * Function to build a sef route
  *
  * @param   JUri  $uri  The uri
  *
  * @return  void
  */
 protected function _buildSefRoute($uri)
 {
     // Get the route
     $route = $uri->getPath();
     // Get the query data
     $query = $uri->getQuery(true);
     if (!isset($query['option'])) {
         return;
     }
     $app = JApplication::getInstance('site');
     $menu = $app->getMenu();
     /*
      * Build the component route
      */
     $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $query['option']);
     $tmp = '';
     $itemID = !empty($query['Itemid']) ? $query['Itemid'] : null;
     // Use the component routing handler if it exists
     $path = JPATH_SITE . '/components/' . $component . '/router.php';
     // Use the custom routing handler if it exists
     if (file_exists($path) && !empty($query)) {
         require_once $path;
         $function = substr($component, 4) . 'BuildRoute';
         $function = str_replace(array("-", "."), "", $function);
         $parts = $function($query);
         // Encode the route segments
         if ($component != 'com_search') {
             // Cheep fix on searches
             $parts = $this->_encodeSegments($parts);
         } else {
             // Fix up search for URL
             $total = count($parts);
             for ($i = 0; $i < $total; $i++) {
                 // Urlencode twice because it is decoded once after redirect
                 $parts[$i] = urlencode(urlencode(stripcslashes($parts[$i])));
             }
         }
         $result = implode('/', $parts);
         $tmp = $result != "" ? $result : '';
     }
     /*
      * Build the application route
      */
     $built = false;
     if (!empty($query['Itemid'])) {
         $item = $menu->getItem($query['Itemid']);
         if (is_object($item) && $query['option'] == $item->component) {
             if (!$item->home || $item->language != '*') {
                 $tmp = !empty($tmp) ? $item->route . '/' . $tmp : $item->route;
             }
             $built = true;
         }
     }
     if (empty($query['Itemid']) && !empty($itemID)) {
         $query['Itemid'] = $itemID;
     }
     if (!$built) {
         $tmp = 'component/' . substr($query['option'], 4) . '/' . $tmp;
     }
     if ($tmp) {
         $route .= '/' . $tmp;
     } elseif ($route == 'index.php') {
         $route = '';
     }
     // Unset unneeded query information
     if (isset($item) && $query['option'] == $item->component) {
         unset($query['Itemid']);
     }
     unset($query['option']);
     // Set query again in the URI
     $uri->setQuery($query);
     $uri->setPath($route);
 }
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:80,代码来源:site.php

示例9: pathAddHost

 /**
  * Give a relative path, return path with host.
  *
  * @param   string $path A system path.
  *
  * @return  string  Path with host added.
  */
 public static function pathAddHost($path)
 {
     if (!$path) {
         return '';
     }
     // Build path
     $uri = new \JUri($path);
     if ($uri->getHost()) {
         return $path;
     }
     $uri->parse(\JUri::root());
     $root_path = $uri->getPath();
     if (strpos($path, $root_path) === 0) {
         $num = Utf8String::strlen($root_path);
         $path = Utf8String::substr($path, $num);
     }
     $uri->setPath($uri->getPath() . $path);
     $uri->setScheme('http');
     $uri->setQuery(null);
     return $uri->toString();
 }
开发者ID:Biromain,项目名称:windwalker-joomla-rad,代码行数:28,代码来源:UriHelper.php


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