/** * Set URL for get front-end content. Correct URL * * @param string $url Link * * @return void */ public static function setRenderUrl($url = '') { $uri = new JURI($url); if ($uri->getScheme() == '') { $scheme = 'http'; if (@$_SERVER['HTTPS']) { $scheme = 'https'; } $uri->setScheme($scheme); } @(list($host, $port) = explode(':', $_SERVER['HTTP_HOST'])); if ($uri->getHost() == '') { $uri->setHost($host); } if ($uri->getPort() == '') { $uri->setPort($port); } if (strtolower($uri->getHost()) != strtolower($host)) { self::$_isExternal = true; } else { if (!$uri->hasVar('jsntpl_position')) { $uri->setVar('jsntpl_position', '1'); } if (!$uri->hasVar('secret_key')) { $config = JFactory::getConfig(); $secret = $config->get('secret'); $uri->setVar('secret_key', md5($secret)); } if ($uri->hasVar('Itemid') and $uri->getVar('Itemid') == '') { $uri->delVar('Itemid'); } self::$_renderUrl = $uri->toString(); } }
public function testSetScheme() { $this->object->setScheme('ftp'); $this->assertThat( $this->object->getScheme(), $this->equalTo('ftp') ); }
function ie_png_fix($params, $jyaml) { $document =& JFactory::getDocument(); if ($document->getType() != 'html') { return; } $selector = $params->get('selector', 'img, .pngTrans'); $blank_image = $params->get('blank_image', 1); if ($blank_image) { $script_file = 'hm_iepngfix_pre.htc'; } else { $script_file = 'hm_iepngfix.htc'; } $url = JURI::base(false); $uri = new JURI($url); $site_path = $uri->getScheme() . '://' . $uri->getHost() . JURI::base(true); $style = $selector . ' {behavior: url(' . $site_path . '/templates/' . $jyaml->template . '/plugins/ie_png_fix/scripts/' . $script_file . ');}'; $jyaml->addStyleDeclaration(' ' . $style, 'msie 5.5'); $jyaml->addStyleDeclaration(' ' . $style, 'msie 6'); }
/** * 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; }
private function getButtons(&$article) { $view = $this->params->get('view'); $currentView = JRequest::getWord("view"); // Check where we are able to show buttons? $showInArticles = $this->params->get('showInArticles'); /** Check for selected views, which will display the buttons. **/ /** If there is a specific set and do not match, return an empty string.**/ if ($showInArticles and strcmp("article", $currentView) != 0) { return ""; } $excludedCats = $this->params->get('excludeCats'); if (!empty($excludedCats)) { $excludedCats = explode(',', $excludedCats); } settype($excludedCats, 'array'); JArrayHelper::toInteger($excludedCats); $excludeArticles = $this->params->get('excludeArticles'); if (!empty($excludeArticles)) { $excludeArticles = explode(',', $excludeArticles); } settype($excludeArticles, 'array'); JArrayHelper::toInteger($excludeArticles); // Included Articles $includedArticles = $this->params->get('includeArticles'); if (!empty($includedArticles)) { $includedArticles = explode(',', $includedArticles); } settype($includedArticles, 'array'); JArrayHelper::toInteger($includedArticles); if (!in_array($article->id, $includedArticles)) { // Check exluded views if (in_array($article->catid, $excludedCats) or in_array($article->id, $excludeArticles)) { return ""; } } $html = ""; $style = MV_SOCIAL_BUTTONS_URL . "style.css"; $doc = JFactory::getDocument(); /* @var $doc JDocumentHtml */ $doc->addStyleSheet($style); $html .= '<div class="mv-social-buttons-box">'; if ($this->params->get('showTitle')) { $html .= '<h4>' . $this->params->get('title') . '</h4>'; } $html .= '<div class="' . $this->params->get('displayLines') . '">'; $html .= '<div class="' . $this->params->get('displayIcons') . '">'; $url = JURI::base(); $url = new JURI($url); $root = $url->getScheme() . "://" . $url->getHost(); $link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug), false); $link = $root . $link; $title = rawurlencode($article->title); $link = rawurlencode($link); if ($this->params->get("displayDelicious")) { $html .= $this->getDeliciousButton($title, $link); } if ($this->params->get("displayDigg")) { $html .= $this->getDiggButton($title, $link); } if ($this->params->get("displayFacebook")) { $html .= $this->getFacebookButton($title, $link); } if ($this->params->get("displayGoogle")) { $html .= $this->getGoogleButton($title, $link); } if ($this->params->get("displayTechnorati")) { $html .= $this->getTechnoratiButton($title, $link); } if ($this->params->get("displayTwitter")) { $html .= $this->getTwitterButton($title, $link); } if ($this->params->get("displayLinkedIn")) { $html .= $this->getLinkedInButton($title, $link); } if ($this->params->get("displayVkruButton")) { $html .= $this->getVkruButton($title, $link); } if ($this->params->get("displayLivejButton")) { $html .= $this->getLivejButton($title, $link); } if ($this->params->get("displayMoymirButton")) { $html .= $this->getMoymirButton($title, $link); } if ($this->params->get("displayYaruButton")) { $html .= $this->getYaruButton($title, $link); } if ($this->params->get("displayOdnoklassnikiButton")) { $html .= $this->getOdnoklassnikiButton($title, $link); } if ($this->params->get("displayLiveinternetButton")) { $html .= $this->getLiveinternetButton($title, $link); } if ($this->params->get("displayBobrdobrButton")) { $html .= $this->getBobrdobrButton($title, $link); } // Get extra social buttons $html .= $this->getExtraButtons($title, $link, $this->params); $html .= '</div></div></div>'; return $html; }
private static function get_current_protocol() { $u = new JURI(JURI::root()); return $u->getScheme(); }
private function getButtons($article) { // excluded view mode if (!$this->view()) { return ''; } // excluded categories or articles $categories = $this->params->get('categories', array()); if (in_array($article->catid, $categories) && $this->params->get('categories_option') == 'exclude' || !in_array($article->catid, $categories) && $this->params->get('categories_option') == 'include') { return ''; } $articles = trim($this->params->get('articles')); if (!empty($articles)) { $articles = explode(',', $articles); } settype($articles, 'array'); if (in_array($article->id, $articles) && $this->params->get('articles_option') == 'exclude' || !in_array($article->id, $articles) && $this->params->get('articles_option') == 'include') { return ''; } // get article link and title $url = JURI::base(); $url = new JURI($url); $root = $url->getScheme() . '://' . $url->getHost(); $link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug)); $link = $root . $link; $title = rawurlencode($article->title); // buttons $style = trim($this->params->get('button_style', '')); !empty($style) ? $style = ' style="' . $style . '"' : NULL; $buttons = array(); $this->params->get('displayFacebook') ? array_push($buttons, $this->getFacebookButton($style, $title, $link)) : NULL; $this->params->get('displayTwitter') ? array_push($buttons, $this->getTwitterButton($style, $title, $link)) : NULL; $this->params->get('displayMixxMN') ? array_push($buttons, $this->getMixxMNButton($style, $link)) : NULL; $this->params->get('displayGooglePlus') ? array_push($buttons, $this->getGooglePlusButton()) : NULL; $this->params->get('displayBiznetworkMN') ? array_push($buttons, $this->getBiznetworkMNButton()) : NULL; $buttons = implode(' ', $buttons); // og:tags for Facebook if ($this->params->get('og_tags', 1)) { isset($article->fulltext) ? $fulltext = $article->fulltext : ($fulltext = ''); $fbimage = $this->catch_first_image($article->introtext . $fulltext); if (empty($fbimage)) { $fbimage = trim($this->params->get('og_image', JE_SOCIAL_SHARE_BUTTONS_URL . 'state_emblem_of_mongolia.png')); } $fbimage = JURI::base() . $fbimage; $mainframe = JFactory::getApplication(); $site_name = $mainframe->getCfg('sitename'); $metadesc = trim($article->metadesc); if (empty($metadesc)) { if ($this->params->get('og_description', 'from_metadesc') == 'from_metadesc') { $metadesc = $mainframe->getCfg('metadesc'); } else { // from_article $metadesc = mb_substr(strip_tags($article->introtext . $fulltext), 0, 160, 'utf8'); } } $doc = JFactory::getDocument(); $doc->addCustomTag('<meta property="og:title" content="' . $article->title . '" />'); $doc->addCustomTag('<meta property="og:type" content="article" />'); $doc->addCustomTag('<meta property="og:url" content="' . $link . '" />'); $doc->addCustomTag('<meta property="og:image" content="' . $fbimage . '" />'); $doc->addCustomTag('<meta property="og:site_name" content="' . $site_name . '" />'); $doc->addCustomTag('<meta property="og:description" content="' . $metadesc . '" />'); $doc->addCustomTag('<link rel="image_src" href="' . $fbimage . '" />'); } // set title of group of buttons if ($this->params->get('show_title')) { $style = trim($this->params->get('title_style', '')); !empty($style) ? $style = ' style="' . $style . '"' : NULL; $title = '<div class="socialsharebuttonstitle" id="socialsharebuttonstitle"' . $style . '>' . $this->params->get('title') . '</div>'; } else { $title = ''; } // set style of main div element $style = trim($this->params->get('main_style', '')); !empty($style) ? $style = ' style="' . $style . '"' : NULL; // result return '<div class="socialsharebuttonsbox" id="socialsharebuttonsbox"' . $style . '>' . $title . $buttons . '</div>'; }
<?php //no direct access defined('_JEXEC') or die('Restricted Access'); $params = JFactory::getApplication()->getTemplate(true)->params; if ($params->get('social_share')) { $url = JRoute::_(ContentHelperRoute::getArticleRoute($displayData->id . ':' . $displayData->alias, $displayData->catid, $displayData->language)); $root = JURI::base(); $root = new JURI($root); $url = $root->getScheme() . '://' . $root->getHost() . $url; echo '<div class="sp-social-share clearfix">'; echo '<ul>'; //echo JLayoutHelper::render( 'joomla.content.social_share.social.facebook', array( 'item'=>$displayData, 'params'=>$params, 'url'=>$url ) ); //echo JLayoutHelper::render( 'joomla.content.social_share.social.twitter', array( 'item'=>$displayData, 'params'=>$params, 'url'=>$url ) ); //echo JLayoutHelper::render( 'joomla.content.social_share.social.google_plus', array( 'item'=>$displayData, 'params'=>$params, 'url'=>$url ) ); //echo JLayoutHelper::render( 'joomla.content.social_share.social.pinterest', array( 'item'=>$displayData, 'params'=>$params, 'url'=>$url ) ); echo '</ul>'; echo '</div>'; }
function getSPShare($product) { global $option; //Parameters $layout_style = $this->getParam('layout_style'); $linkedin = $this->getParam('linkedin'); $twitter = $this->getParam('twitter'); $gplus = $this->getParam('gplus'); $pinterest = $this->getParam('pinterest'); $digg = $this->getParam('digg'); $like_btn = $this->getParam('like_btn'); $fb_width = $this->getParam('fb_width'); //Button Style $linkedin_style = $layout_style == 'button_count' ? "right" : "top"; $twitter_style = $layout_style == 'button_count' ? "horizontal" : "vertical"; $gplus_style = $layout_style == 'button_count' ? "medium" : "tall"; $pin_style = $layout_style == 'button_count' ? "horizontal" : "vertical"; $digg_style = $layout_style == 'button_count' ? "DiggCompact" : "DiggMedium"; $like_btn_style = $layout_style == 'button_count' ? "button_count" : "box_count"; // enable commenting if everything is alright $output = ""; /*Article Link*/ $url = JURI::base(); $url = new JURI($url); $this->_url = $url->getScheme() . "://" . $url->getHost() . $_SERVER["REQUEST_URI"]; $this->_text = $product->title; //Javascript $doc = JFactory::getDocument(); if ($linkedin) { $doc->addScript('http://platform.linkedin.com/in.js'); } //Javascript for Linkedin share button if ($twitter) { $doc->addScript('http://platform.twitter.com/widgets.js'); } //Javascript for Twitter Button if ($gplus) { $doc->addScript('https://apis.google.com/js/plusone.js'); } //Javascript for The + Button if ($digg) { $doc->addScriptDeclaration("\n\t\t\t\t\t(function() {\n\t\t\t\t\t var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];\n\t\t\t\t\t s.type = 'text/javascript';\n\t\t\t\t\t s.async = true;\n\t\t\t\t\t s.src = 'http://widgets.digg.com/buttons.js';\n\t\t\t\t\t s1.parentNode.insertBefore(s, s1);\n\t\t\t\t\t})();\t\t\t\t\n\t\t\t\t"); } //Javascript for digg Button if ($like_btn != 3) { echo '<div id="fb-root"></div>'; echo "<script>(function(d, s, id) {\n\t\t\t\t\tvar js, fjs = d.getElementsByTagName(s)[0];\n\t\t\t\t\tif (d.getElementById(id)) return;\n\t\t\t\t\tjs = d.createElement(s); js.id = id;\n\t\t\t\t\tjs.src = '//connect.facebook.net/en_US/all.js#xfbml=1';\n\t\t\t\t\tfjs.parentNode.insertBefore(js, fjs);\n\t\t\t\t}(document, 'script', 'facebook-jssdk'));</script>"; $output .= "<div class='spshare pull-right'>"; //$output .= "<div class='sp_fblike spshare_fltlft'><div class='fb-like' data-action='like' data-href='" . $this->_url . "' data-send='true' data-layout='" . $like_btn_style . "' data-width='" . $fb_width . "' data-show-faces='false'></div></div>"; /* $doc->addScriptDeclaration(" (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = '//connect.facebook.net/en_US/all.js#xfbml=1'; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); "); //Javascript for Facebook Send Button $doc->addScriptDeclaration(" (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = '//connect.facebook.net/en_US/all.js#xfbml=1'; d.getElementsByTagName('head')[0].appendChild(js); }(document)); "); */ } //Javascript for Facebook Send Button //Output if ($linkedin) { $output .= "<div class='sp_linkedin spshare_fltlft'><script type='IN/Share' data-url=" . $this->_url . " data-counter='" . $linkedin_style . "'></script></div>"; } if ($twitter) { $output .= "<div class='sp_twitter spshare_fltlft'><a href='https://twitter.com/share' class='twitter-share-button' data-text='" . $article->title . "' data-url='" . $this->_url . "' data-count='" . $twitter_style . "'>Tweet</a></div>"; } if ($gplus) { $output .= "<div class='sp_plusone spshare_fltlft'><g:plusone href='" . $this->_url . "' size='" . $gplus_style . "'></g:plusone></div>"; } if ($pinterest) { $output .= "<div class='sp_pinterest spshare_fltlft'><a href='http://pinterest.com/pin/create/button/?url=" . $this->_url . "&media=" . $this->_image . "&description=" . $this->_text . "' class='pin-it-button' count-layout='" . $pin_style . "'><img border='0' src='//assets.pinterest.com/images/PinExt.png' title='Pin It' /></a></div>"; } if ($digg) { $output .= "<div class='sp_digg spshare_fltlft'><a class='DiggThisButton " . $digg_style . "' href='http://digg.com/submit?url='" . $this->_url . "'></a></div>"; } if ($like_btn == 1) { $output .= '<div class="sp_fblike spshare_fltlft"><div class="fb-like" data-href="' . $this->_url . '" data-width="' . $fb_width . '" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div></div>'; } else { if ($like_btn == 2) { $output .= '<div class="sp_fblike spshare_fltlft"><div class="fb-like" data-href="' . $this->_url . '" data-width="' . $fb_width . '" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div></div>'; } } $output .= "<div style='clear:both'></div></div>"; $this->getStyle(); return $output; }
/** * Set URL for get front-end content. Correct URL * * @param string $url Link * * @return void */ public function setRenderUrl($url = '') { $uri = new JURI($url); if ($uri->getScheme() == '') { $scheme = 'http'; if (@$_SERVER['HTTPS']) { $scheme = 'https'; } $uri->setScheme($scheme); } @(list($host, $port) = explode(':', $_SERVER['HTTP_HOST'])); if ($uri->getHost() == '') { $uri->setHost($host); } if ($uri->getPort() == '') { $uri->setPort($port); } if (JString::strtolower($uri->getHost()) != JString::strtolower($host)) { $this->_isExternal = true; } else { if (!$uri->hasVar('poweradmin')) { $uri->setVar('poweradmin', '1'); } if ($uri->hasVar('Itemid') and $uri->getVar('Itemid') == '') { $uri->delVar('Itemid'); } $this->_renderUrl = $uri->toString(); } }