本文整理汇总了PHP中JURI::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP JURI::toString方法的具体用法?PHP JURI::toString怎么用?PHP JURI::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JURI
的用法示例。
在下文中一共展示了JURI::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajaxGetRender
/**
*
* Ajax render to store in session
*/
public function ajaxGetRender()
{
/** load libraries for the system rener **/
JSNFactory::localimport('libraries.joomlashine.mode.rawmode');
JSNFactory::localimport('libraries.joomlashine.menu.menuitems');
/** get url **/
$render_url = JRequest::getVar('render_url', '');
$urlRender = base64_decode($render_url);
$session = JSession::getInstance('files', array('name' => 'jsnpoweradmin'));
if ($render_url == '') {
$urlRender = JSNDatabase::getDefaultPage()->link;
}
$currUri = new JURI($urlRender);
if (!$currUri->hasVar('Itemid')) {
$currUri->setVar('Itemid', JSNDatabase::getDefaultPage()->id);
}
$urlString = $currUri->toString();
$session->set('rawmode_render_url', base64_encode($urlString));
$parts = JString::parse_url($urlString);
if (!empty($parts['query'])) {
parse_str($parts['query'], $params);
} else {
$params = array();
}
$jsntemplate = JSNFactory::getTemplate();
$jsnrawmode = JSNRawmode::getInstance($params);
$jsnrawmode->setParam('positions', $jsntemplate->loadXMLPositions());
$jsnrawmode->renderAll();
$session = JSession::getInstance('files', array('name' => 'jsnajaxgetrender'));
$session->set('component', $jsnrawmode->getHTML('component'));
$session->set('jsondata', $jsnrawmode->getScript('positions', 'JSON'));
jexit('success');
}
示例2: modifyAttrs
function modifyAttrs($lnkAttrs, $imgAttrs, $group, $params)
{
$lnkAttrs['rel'] = 'sexylightbox';
if ($group) {
$lnkAttrs['rel'] .= '[' . $group . ']';
}
$link = $lnkAttrs['href'];
$bgColor = $params->get('lightbox_bgColor');
if ($this->isLink($link)) {
$uri = new JURI($link);
$uri->setVar('TB_iframe', 'true');
$uri->setVar('height', intval($params->get('lightbox_height'), 10));
$uri->setVar('width', intval($params->get('lightbox_width'), 10));
if ($bgColor) {
$uri->setVar('background', $bgColor);
}
$lnkAttrs['href'] = $uri->toString();
} else {
if ($bgColor) {
$uri = new JURI($link);
$uri->setVar('background', $bgColor);
$lnkAttrs['href'] = $uri->toString();
}
}
return parent::modifyAttrs($lnkAttrs, $imgAttrs, $group, $params);
}
示例3: modifyAttrs
function modifyAttrs($lnkAttrs, $imgAttrs, $group, $params)
{
$lnkAttrs['rel'] = 'prettyPhoto';
if ($group) {
$lnkAttrs['rel'] .= '[' . $group . ']';
}
$link = $lnkAttrs['href'];
if ($this->isLink($link)) {
$uri = new JURI($link);
$uri->setVar('iframe', 'true');
if (!$uri->getVar('height')) {
$uri->setVar('height', intval($params->get('lightbox_height'), 10));
} else {
$height = $uri->getVar('height');
$uri->delVar('height');
$uri->setVar('height', $height);
}
if (!$uri->getVar('width')) {
$uri->setVar('width', intval($params->get('lightbox_width'), 10));
} else {
$width = $uri->getVar('width');
$uri->delVar('width');
$uri->setVar('width', $width);
}
$lnkAttrs['href'] = $uri->toString();
}
return parent::modifyAttrs($lnkAttrs, $imgAttrs, $group, $params);
}
示例4: testToString
public function testToString()
{
$this->object->parse('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment');
$this->assertThat($this->object->toString(), $this->equalTo('http://someuser:somepass@www.example.com:80/path/file.html?var=value#fragment'));
$this->object->setQuery('somevar=somevalue');
$this->object->setVar('somevar2', 'somevalue2');
$this->object->setScheme('ftp');
$this->object->setUser('root');
$this->object->setPass('secret');
$this->object->setHost('www.example.org');
$this->object->setPort('8888');
$this->object->setFragment('someFragment');
$this->object->setPath('/this/is/a/path/to/a/file');
$this->assertThat($this->object->toString(), $this->equalTo('ftp://root:secret@www.example.org:8888/this/is/a/path/to/a/file?somevar=somevalue&somevar2=somevalue2#someFragment'));
}
示例5: gTranslate
function gTranslate($text, $SourceLan, $ResultLan)
{
$url = new JURI();
// for APIv2
$url->setHost('https://www.googleapis.com/');
$url->setPath('language/translate/v2');
$query['key'] = 'AIzaSyC04nF4KXjfR2VQ0jsFm5vEd9LbyiXqbKw';
$query['q'] = urlencode($text);
$query['source'] = $SourceLan;
$query['target'] = $ResultLan;
if (!$text) {
return;
}
$url->setQuery($query);
$url->toString();
$response = AKHelper::_('curl.getPage', $url->toString());
$json = new JRegistry($response);
$r = $json->get('data.translations');
return $r[0]->translatedText;
}
示例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 Translated text.
*/
public static function gTranslate($text, $SourceLan, $ResultLan)
{
$url = new JURI();
// for 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;
}
$url->setQuery($query);
$url->toString();
$response = AKHelper::_('curl.getPage', $url->toString());
$json = new JRegistry();
$json->loadString($response);
$r = $json->get('data.translations');
return $r[0]->translatedText;
}
示例7: renderItems
/**
* Return HTML, subitems in menu
*
* @param: Array items
* @param: int $menuid
*/
protected function renderItems($mItems, $moduleid)
{
$items = '';
if (count($mItems)) {
for ($i = 0; $i < count($mItems); $i++) {
$publish = $mItems[$i]->published == 1 ? 'Unpublish' : 'Publish';
$class_unpublish = $mItems[$i]->published == 0 ? ' unpublish' : '';
$default = $mItems[$i]->home == 1 ? ' default' : '';
$uri = new JURI($mItems[$i]->link);
$link = $uri->toString();
//if external link
if (!JURI::isInternal($link)) {
$link = $mItems[$i]->link;
} else {
$link = JURI::root() . $link;
}
//if default item
if ($mItems[$i]->home == 1) {
$link = JURI::root();
}
$attributes = $this->getCheckboxAttributes($mItems[$i]->id, $moduleid);
if ($mItems[$i]->type == 'alias') {
$aliasparams = new JRegistry();
$aliasparams->loadString($mItems[$i]->params);
$address_itemid = $aliasparams->get('aliasoptions');
if ((int) $address_itemid > 0) {
$address_item = $this->getMenuItem($address_itemid);
if (!$address_item) {
continue;
}
$link = $address_item->link;
if (strpos($link, '?') === false) {
$link .= '?aliasoptions=' . $address_itemid . '&Itemid=' . $mItems[$i]->id;
} else {
$link .= '&aliasoptions=' . $address_itemid . '&Itemid=' . $mItems[$i]->id;
}
$mItems[$i]->link = $link;
}
}
if ($this->hasChild($mItems[$i]->id)) {
$subItems = $this->getItems($mItems[$i]->menutype, $mItems[$i]->id);
//Render item
$items .= JSNHtmlHelper::openTag('li') . JSNHtmlHelper::addInputTag('checkbox', $attributes) . JSNHtmlHelper::openTag('a', array('conClick' => 'javascript:void(0);', 'class' => $default . $class_unpublish, 'href' => $link, 'title' => $this->getMenuItemType($mItems[$i]->link))) . $mItems[$i]->title . JSNHtmlHelper::closeTag('a') . JSNHtmlHelper::openTag('ul', array('class' => 'jsn-menu-items', 'id' => 'item-' + $mItems[$i]->id)) . $this->renderItems($subItems, $moduleid) . JSNHtmlHelper::closeTag('ul') . JSNHtmlHelper::closeTag('li');
} else {
$items .= JSNHtmlHelper::openTag('li') . JSNHtmlHelper::addInputTag('checkbox', $attributes) . JSNHtmlHelper::openTag('a', array('onClick' => 'javascript:void(0);', 'class' => $default . $class_unpublish, 'href' => $link, 'title' => $this->getMenuItemType($mItems[$i]->link))) . $mItems[$i]->title . JSNHtmlHelper::closeTag('a') . JSNHtmlHelper::closeTag('li');
}
}
}
return $items;
}
示例8: getObjectInfo
function getObjectInfo($id, $language = null)
{
$db = JFactory::getDBO();
$article = null;
$link = null;
require_once JPATH_ROOT . '/components/com_content/helpers/route.php';
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.id, a.title, a.created_by, a.access, a.alias, a.catid, a.language');
$query->from('#__content AS a');
// Join over the categories.
$query->select('c.title AS category_title, c.path AS category_route, c.access AS category_access, c.alias AS category_alias');
$query->join('LEFT', '#__categories AS c ON c.id = a.catid');
$query->where('a.id = ' . (int) $id);
$db->setQuery($query);
$article = $db->loadObject();
if (!empty($article)) {
$user = JFactory::getUser();
$article->slug = $article->alias ? $article->id . ':' . $article->alias : $article->id;
$article->catslug = $article->category_alias ? $article->catid . ':' . $article->category_alias : $article->catid;
$authorised = JAccess::getAuthorisedViewLevels($user->get('id'));
$checkAccess = in_array($article->access, $authorised);
if ($checkAccess) {
$link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->language));
} else {
$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->language));
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
$ItemId = $active->id;
$link = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $ItemId);
$uri = new JURI($link);
$uri->setVar('return', base64_encode($returnURL));
$link = $uri->toString();
}
}
$info = new JCommentsObjectInfo();
if (!empty($article)) {
$info->category_id = $article->catid;
$info->title = $article->title;
$info->access = $article->access;
$info->userid = $article->created_by;
$info->link = $link;
}
return $info;
}
示例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 = JString::strlen($root_path);
$path = JString::substr($path, $num);
}
$uri->setPath($uri->getPath() . $path);
$uri->setScheme('http');
$uri->setQuery(null);
return $uri->toString();
}
示例10: modifyAttrs
function modifyAttrs($lnkAttrs, $imgAttrs, $group, $params)
{
if ($group) {
$lnkAttrs['rel'] = $group;
}
if (empty($lnkAttrs['class'])) {
$lnkAttrs['class'] = '';
} else {
$lnkAttrs['class'] .= ' ';
}
$lnkAttrs['class'] .= 'arifancybox';
$link = $lnkAttrs['href'];
if ($this->isLink($link)) {
$uri = new JURI($link);
$lnkParams = array('width' => intval($uri->getVar('width') ? $uri->getVar('width') : $params->get('lightbox_width'), 10), 'height' => intval($uri->getVar('height') ? $uri->getVar('height') : $params->get('lightbox_height'), 10));
$lnkAttrs['class'] .= ' iframe ' . str_replace('"', '"', AriJSONHelper::encode($lnkParams));
$uri->delVar('width');
$uri->delVar('height');
$lnkAttrs['href'] = $uri->toString();
}
return parent::modifyAttrs($lnkAttrs, $imgAttrs, $group, $params);
}
示例11: JURI
function _uriToUrl($uri, $removeVariables = null)
{
// Create new JURI object
$url = new JURI($uri->toString(array('path', 'query', 'fragment')));
// Remove variables if needed
if (!empty($removeVariables)) {
if (is_array($removeVariables)) {
foreach ($removeVariables as $var) {
$url->delVar($var);
}
} else {
$url->delVar($removeVariables);
}
}
// sort variables
ksort($url->_vars);
$opt = $url->getVar('option');
if (!is_null($opt)) {
$url->delVar('option');
array_unshift($url->_vars, array('option' => $opt));
}
$url->_query = null;
// Create string for db
return $url->toString(array('path', 'query'));
}
示例12: showImage
/**
*
* Add image tag to
*
* @param String $src
* @param String $attrs
*/
public static function showImage($src, $attrs = "")
{
$uri = new JURI($src);
return '<img src="' . JURI::root() . $uri->toString() . '" ' . $attrs . ' />';
}
示例13: prepareSlides
function prepareSlides($slides, $params)
{
$newSlides = array();
$target = $params->get('customLinkTarget');
if (empty($target)) {
$target = $params->get('linkTarget', '_self');
}
$defLink = $params->get('defaultLink');
$baseUri = JURI::base(true);
$lightboxEngine = AriImageSliderHelper::getLightboxEngine($params);
$lightboxGrouping = (bool) $params->get('lightbox_grouping', true);
$lightboxGroup = $lightboxGrouping ? uniqid('cc_') : null;
foreach ($slides as $slide) {
$slideLink = !empty($slide['link']) ? $slide['link'] : $defLink;
if (empty($slide['link']) && !empty($defLink)) {
$slide['link'] = $defLink;
}
$isLink = !empty($slideLink);
$description = isset($slide['description']) ? $slide['description'] : '';
$altText = isset($slide['alt']) ? $slide['alt'] : '';
$lnkAttrs = null;
$imgAttrs = array('src' => $baseUri . '/' . $slide['image'], 'alt' => $altText, 'title' => $description, 'class' => 'imageslider-item');
if (!empty($slide['width'])) {
$imgAttrs['width'] = $slide['width'];
}
if (!empty($slide['height'])) {
$imgAttrs['height'] = $slide['height'];
}
if ($isLink) {
$lnkAttrs = array('href' => $slideLink, 'target' => $target);
if ($description) {
$lnkAttrs['title'] = $description;
}
$skip_lb = false;
if (!is_null($lightboxEngine) && strpos($slideLink, 'skip_lb') !== false) {
$uri = new JURI($slideLink);
$skip_lb = (bool) $uri->getVar('skip_lb');
$uri->delVar('skip_lb');
$slideLink = $uri->toString();
$lnkAttrs['href'] = $slideLink;
}
if (!$skip_lb && !is_null($lightboxEngine)) {
list($lnkAttrs, $imgAttrs) = $lightboxEngine->modifyAttrs($lnkAttrs, $imgAttrs, $lightboxGroup, $params);
} else {
$originalLink = $slideLink;
if (strpos($originalLink, '_target') !== false) {
$uri = new JURI($originalLink);
$linkTarget = $uri->getVar('_target');
if (!is_null($linkTarget)) {
$uri->delVar('_target');
$lnkAttrs['target'] = $linkTarget;
$lnkAttrs['href'] = $uri->toString();
}
}
}
}
$slide['lnkAttrs'] = $lnkAttrs;
$slide['imgAttrs'] = $imgAttrs;
$newSlides[] = $slide;
}
return $newSlides;
}
示例14: array
function onTP_Processpayment($data, $vars = array())
{
$isValid = true;
$error = array();
$error['code'] = '';
$error['desc'] = '';
$trxnstatus = '';
JLoader::import('joomla.utilities.date');
// Check if we're supposed to handle this
JLoader::import('joomla.environment.uri');
switch ($this->params->get('site', 0)) {
case '0':
default:
$apiURL = 'https://au.ewaygateway.com/Result';
break;
case '1':
$apiURL = 'https://payment.ewaygateway.com/Result';
break;
case '2':
$apiURL = 'https://nz.ewaygateway.com/Result';
break;
}
$eWayURL = new JURI($apiURL);
$eWayURL->setVar('CustomerID', urlencode($this->params->get('customerid', '')));
$eWayURL->setVar('UserName', urlencode($this->params->get('username', '')));
$eWayURL->setVar('AccessPaymentCode', urlencode($data['AccessPaymentCode']));
$posturl = $eWayURL->toString();
$posturl = str_replace('Result?', 'Result/?', $posturl);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $posturl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
if (defined('CURL_PROXY_REQUIRED')) {
if (CURL_PROXY_REQUIRED == 'True') {
$proxy_tunnel_flag = defined('CURL_PROXY_TUNNEL_FLAG') && strtoupper(CURL_PROXY_TUNNEL_FLAG) == 'FALSE' ? false : true;
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_tunnel_flag);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_PROXY, CURL_PROXY_SERVER_DETAILS);
}
}
$response = curl_exec($ch);
$authecode = $this->fetch_data($response, '<authCode>', '</authCode>');
$responsecode = $this->fetch_data($response, '<responsecode>', '</responsecode>');
$retrunamount = $this->fetch_data($response, '<returnamount>', '</returnamount>');
$trxnnumber = $this->fetch_data($response, '<trxnnumber>', '</trxnnumber>');
$trxnstatus = $this->fetch_data($response, '<trxnstatus>', '</trxnstatus>');
$trxnresponsemessage = $this->fetch_data($response, '<trxnresponsemessage>', '</trxnresponsemessage>');
// order id
$MerchantOption1_orderid = $this->fetch_data($response, '<MerchantOption1>', '</MerchantOption1>');
$MerchantOption2_email = $this->fetch_data($response, '<MerchantOption2>', '</MerchantOption2>');
$merchantreference = $this->fetch_data($response, '<merchantreference>', '</merchantreference>');
$isValid = true;
// Check that the amount is correct // checked in model payment
$rootURL = rtrim(JURI::base(), '/');
$subpathURL = JURI::base(true);
if (!empty($subpathURL) && $subpathURL != '/') {
$rootURL = substr($rootURL, 0, -1 * strlen($subpathURL));
}
//3.compare response order id and send order id in notify URL
if ($isValid) {
if (!empty($vars) && $MerchantOption1_orderid != $vars->order_id) {
$isValid = false;
$trxnstatus = 'ERROR';
$data['error'] = "ORDER_MISMATCH" . "Invalid ORDERID; notify order_is " . $vars->order_id . ", and response " . $MerchantOption1_orderid;
}
}
// amount check
if ($isValid) {
if (!empty($vars)) {
// Check that the amount is correct
$order_amount = (double) $vars->amount;
$return_resp['status'] = '0';
$retrunamount = (double) $retrunamount;
$epsilon = 0.01;
if ($order_amount - $retrunamount > $epsilon) {
$trxnstatus = 'ERROR';
// change response status to ERROR FOR AMOUNT ONLY
$isValid = false;
$data['error'] = "ORDER_AMOUNT_MISTMATCH - order amount= " . $order_amount . ' response order amount = ' . $retrunamount;
}
}
}
$order_status = '';
// Translaet Payment status
$order_status = $this->translateResponse($trxnstatus);
// IF REQUIRE:: add the AfterPaymentCallback events
$data['status'] = $trxnstatus;
//Error Handling
$responseCodes = $this->responseCodes;
$error = array();
if ($responsecode != '00') {
$error['code'] = $responsecode;
$error['desc'] = isset($responsecode) ? $responseCodes[$responsecode] : '';
}
$result = array('order_id' => $MerchantOption1_orderid, 'transaction_id' => $authecode, 'buyer_email' => $MerchantOption2_email, 'status' => $order_status, 'txn_type' => '', 'total_paid_amt' => (double) $retrunamount, 'raw_data' => $response, 'error' => $error);
//return true;
return $result;
}
示例15: explode
function _fixLangSwitcher($reqURI)
{
$isLangFilter = JPluginHelper::isEnabled("system", "languagefilter");
if (!$isLangFilter) {
return $reqURI;
}
$uri = JFactory::getURI();
$app = JFactory::getApplication();
$router = $app->getRouter();
if ($app->isSite()) {
// setup language data
$mode_sef = $router->getMode() == JROUTER_MODE_SEF ? true : false;
$default_lang = JLanguageHelper::getLanguages('lang_code');
if ($mode_sef) {
// Get the route path from the request.
$path = JString::substr($uri->toString(), JString::strlen($uri->base()));
// Apache mod_rewrite is Off
//$path = JFactory::getConfig()->get('sef_rewrite') ? $path : JString::substr($path, 10);
$path = $app->getCfg('sef_rewrite') ? $path : JString::substr($path, 10);
// Trim any spaces or slashes from the ends of the path and explode into segments.
$path = JString::trim($path, '/ ');
$parts = explode('/', $path);
// The language segment is always at the beginning of the route path if it exists.
$langcode = $uri->getVar('lang');
if (!empty($parts) && empty($langcode)) {
$langcode = reset($parts);
}
//set to default language
if (empty($langcode)) {
//$langcode = $default_lang;
// @since 4.0 we get default language from here
$lang = JFactory::getLanguage();
$langcode = $lang->getDefault();
}
//append language code to the request
$reqURI = $reqURI . '/' . $langcode . '/';
} else {
$langcode = $uri->getVar('lang', $default_lang);
//append language code to the request
$tmpURI = new JURI($reqURI);
$tmpURI->setVar('lang', $langcode);
$reqURI = $tmpURI->toString();
}
}
return $reqURI;
}