Пример #1
0
 /**
  * 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();
     }
 }
Пример #2
0
	public function testSetHost() {
		$this->object->setHost('www.example.org');

		$this->assertThat(
			$this->object->getHost(),
			$this->equalTo('www.example.org')
		);
	}
 /**
  * 
  * Fix links
  * 
  * @param String $contents
  */
 public static function fixImageLinks($contents)
 {
     $regex = '/src=(["\'])(.*?)\\1/';
     $count = preg_match_all($regex, $contents, $match);
     if ($count > 0) {
         $changes = $match[2];
         foreach ($changes as $change) {
             $uri = new JURI($change);
             if ($uri->getHost() == '') {
                 $uri = new JURI(JURI::root() . $change);
             }
             $contents = str_replace('src="' . $change . '"', 'src="' . $uri->toString() . '"', $contents);
         }
     }
     return $contents;
 }
Пример #4
0
 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');
 }
Пример #5
0
 /**
  * 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();
 }
Пример #6
0
<?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>';
}
Пример #7
0
 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;
 }
Пример #8
0
 function _determineLanguage($getLang = null, $redir = false, $useMainLang = false)
 {
     // set the language for JoomFish
     if (SEFTools::JoomFishInstalled()) {
         $sefConfig =& SEFConfig::getConfig();
         $registry =& JFactory::getConfig();
         // Check if the Jfrouter is enabled
         $jfrouterEnabled = JPluginHelper::isEnabled('system', 'jfrouter');
         // save the default language of the site if needed
         if (!$jfrouterEnabled) {
             $locale = $registry->getValue('config.language');
             $GLOBALS['mosConfig_defaultLang'] = $locale;
             $registry->setValue("config.defaultlang", $locale);
         }
         // get instance of JoomFishManager to obtain active language list and config values
         $jfm =& JoomFishManager::getInstance();
         // Get language from request
         if (!empty($getLang)) {
             $lang = $getLang;
         }
         // Try to get language code from JF cookie
         if ($sefConfig->jfLangCookie) {
             $jfCookie = JRequest::getVar('jfcookie', null, 'COOKIE');
             if (isset($jfCookie['lang'])) {
                 $cookieCode = $jfCookie['lang'];
             }
         }
         // Try to find language from browser settings
         if ($sefConfig->jfBrowserLang && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
             $active_iso = array();
             $active_isocountry = array();
             $active_code = array();
             $activeLanguages = $jfm->getActiveLanguages();
             if (count($activeLanguages) > 0) {
                 foreach ($activeLanguages as $alang) {
                     $active_iso[] = $alang->iso;
                     if (preg_match('/[_-]/i', $alang->iso)) {
                         $iso = str_replace('_', '-', $alang->iso);
                         $isocountry = explode('-', $iso);
                         $active_isocountry[] = $isocountry[0];
                     }
                     $active_code[] = $alang->shortcode;
                 }
                 // figure out which language to use - browser languages are based on ISO codes
                 $browserLang = explode(',', $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
                 foreach ($browserLang as $blang) {
                     if (in_array($blang, $active_iso)) {
                         $client_lang = $blang;
                         break;
                     }
                     $shortLang = substr($blang, 0, 2);
                     if (in_array($shortLang, $active_isocountry)) {
                         $client_lang = $shortLang;
                         break;
                     }
                     // compare with code
                     if (in_array($shortLang, $active_code)) {
                         $client_lang = $shortLang;
                         break;
                     }
                 }
                 if (!empty($client_lang)) {
                     if (strlen($client_lang) == 2) {
                         $browserCode = SEFTools::getLangLongCode($client_lang);
                     } else {
                         $browserCode = $client_lang;
                     }
                 }
             }
         }
         if (!$jfrouterEnabled && $redir && $sefConfig->langPlacement != _COM_SEF_LANG_DOMAIN && (isset($cookieCode) || isset($browserCode)) && $sefConfig->mainLanguage != '0') {
             if (isset($cookieCode)) {
                 $sc = SEFTools::getLangCode($cookieCode);
             } else {
                 $sc = SEFTools::getLangCode($browserCode);
             }
             // Check the referer to see if we should redirect
             $shouldRedir = false;
             if (isset($_SERVER['HTTP_REFERER'])) {
                 $refUri = new JURI($_SERVER['HTTP_REFERER']);
                 $uri = JURI::getInstance();
                 $refHost = $refUri->getHost();
                 $host = $uri->getHost();
                 if ($refHost != $host) {
                     $shouldRedir = true;
                 }
             } else {
                 $shouldRedir = true;
             }
             if ($shouldRedir) {
                 if (!empty($lang) && $sc != $lang || empty($lang) && $sc != $sefConfig->mainLanguage) {
                     // Redirect to correct site
                     $mainframe =& JFactory::getApplication();
                     $href = JRoute::_('index.php?lang=' . $sc, false);
                     $mainframe->redirect($href);
                     exit;
                 }
             }
         }
         // Check if language is selected
         if (empty($lang) && !$jfrouterEnabled) {
             // If route and query string are empty, use the main language
             // note: removed  && $redir  - it was not possible to switch language to main language
             // on other page than homepage (let's see if it causes any other problem)
             // note: added $useMainLang - now it should work for both the VM checkout and using
             // main language with component's own router
             if ($useMainLang && (empty($code) || !JLanguage::exists($code))) {
                 if ($sefConfig->mainLanguage != '0') {
                     $code = SEFTools::GetLangLongCode($sefConfig->mainLanguage);
                 }
             }
             // Try to get language code from JF cookie
             if (empty($code) || !JLanguage::exists($code)) {
                 if (isset($cookieCode)) {
                     $code = $cookieCode;
                 }
             }
             // Try to get language from browser if needed
             if (empty($code) || !JLanguage::exists($code)) {
                 if (isset($browserCode)) {
                     $code = $browserCode;
                 }
             }
             // Get language from configuration if needed
             if (empty($code) || !JLanguage::exists($code)) {
                 if ($sefConfig->mainLanguage != '0') {
                     $code = SEFTools::GetLangLongCode($sefConfig->mainLanguage);
                 }
             }
             // Get default language if needed
             if (empty($code) || !JLanguage::exists($code)) {
                 $code = $registry->getValue('config.language');
             }
         }
         // get language long code if needed
         if (empty($code)) {
             if (empty($lang)) {
                 return;
             }
             $code = SEFTools::getLangLongCode($lang);
         }
         if (!empty($code)) {
             $jfrparams = $registry->getValue('jfrouter.params');
             // set the site language
             $resetLang = false;
             if ($code != SEFTools::getLangLongCode()) {
                 if (!$jfrouterEnabled || $jfrouterEnabled && $jfrparams->get('sefordomain', 'sefprefix') == 'sefprefix') {
                     $language =& JFactory::getLanguage();
                     $language->setLanguage($code);
                     $language->load();
                     // set the backward compatible language
                     $backLang = $language->getBackwardLang();
                     $GLOBALS['mosConfig_lang'] = $backLang;
                     $registry->setValue("config.lang", $backLang);
                     $resetLang = true;
                 }
             }
             // set joomfish language if needed
             if ($resetLang || !$jfrouterEnabled) {
                 $jfLang = TableJFLanguage::createByJoomla($code);
                 $registry->setValue("joomfish.language", $jfLang);
                 // set some more variables
                 $mainframe =& JFactory::getApplication();
                 $registry->setValue("config.multilingual_support", true);
                 $mainframe->setUserState('application.lang', $jfLang->code);
                 $registry->setValue("config.jflang", $jfLang->code);
                 $registry->setValue("config.lang_site", $jfLang->code);
                 $registry->setValue("config.language", $jfLang->code);
                 $registry->setValue("joomfish.language", $jfLang);
                 // overwrite global config with values from $jfLang if set to in JoomFish
                 $jfparams = JComponentHelper::getParams("com_joomfish");
                 $overwriteGlobalConfig = $jfparams->get('overwriteGlobalConfig', 0);
                 if ($overwriteGlobalConfig) {
                     // We should overwrite additional global variables based on the language parameter configuration
                     $langParams = new JParameter($jfLang->params);
                     $paramarray = $langParams->toArray();
                     foreach ($paramarray as $key => $val) {
                         $registry->setValue("config." . $key, $val);
                         if (defined("_JLEGACY")) {
                             $name = 'mosConfig_' . $key;
                             $GLOBALS[$name] = $val;
                         }
                     }
                 }
                 // set the cookie with language
                 if (!$jfrouterEnabled && $sefConfig->jfLangCookie || $jfrouterEnabled && $jfrparams->get('enableCookie', 1)) {
                     setcookie("lang", "", time() - 1800, "/");
                     setcookie("jfcookie", "", time() - 1800, "/");
                     setcookie("jfcookie[lang]", $code, time() + 24 * 3600, '/');
                 }
             }
         }
     }
 }
Пример #9
0
 private static function get_current_domain()
 {
     $u = new JURI(JURI::root());
     return $u->getHost();
 }
Пример #10
0
 /**
  * Create and return the pagination data object.
  *
  * @return  object  Pagination data object.
  * @since   11.1
  */
 protected function _buildDataObject()
 {
     jimport('joomla.version');
     $version = new JVersion();
     $JoomlaVersionRelease = $version->RELEASE;
     $yg_anchor = '#youtubegallery';
     $data = new stdClass();
     $WebsiteRoot = '';
     if ($JoomlaVersionRelease >= 1.6) {
         $WebsiteRoot = JURI::base();
         $u = JURI::getInstance();
         $uri = $u->toString();
         $URLPath = $u->getPath();
         if ($WebsiteRoot[strlen($WebsiteRoot) - 1] != '/') {
             //Root must have slash / in the end
             $WebsiteRoot .= '/';
         }
         if ($URLPath[0] != '/') {
             //Root must have slash / in the end
             $URLPath = '/' . $URLPath;
         }
         $a = explode('/', $WebsiteRoot);
         //print_r($a);
         $b = explode('/', $URLPath);
         //print_r($b);
         $s = -1;
         $ca = count($a);
         //if($a[$ca-1]=='')
         //$ca=$ca-1;
         for ($i = 0; $i < count($b) and $i < $ca - 3; $i++) {
             if ($a[$ca - 1 - $i] == $b[$i]) {
                 $s = $i;
             } else {
                 break;
             }
         }
         //echo '$s='.$s.'<br/>';
         if ($s != -1) {
             $c = array();
             for ($i = $s + 1; $i < count($b); $i++) {
                 $c[] = $b[$i];
             }
             $URLPath = implode('/', $c);
             //print_r($c);
         }
         //echo '$URLPath='.$URLPath.'<br/>';
     } else {
         $juri = new JURI();
         $WebsiteRoot = $juri->getHost();
         $URLPath = $_SERVER['REQUEST_URI'];
         // example:  /index.php'
     }
     if ($WebsiteRoot[strlen($WebsiteRoot) - 1] != '/') {
         //Root must have slash / in the end
         $WebsiteRoot .= '/';
     }
     if ($URLPath != '') {
         if ($URLPath[0] == '/') {
             $URLPath = substr($URLPath, 1);
         }
     }
     $Translations = array();
     if ($JoomlaVersionRelease >= 1.6) {
         $Translations['all'] = JText::_('JLIB_HTML_VIEW_ALL');
         $Translations['start'] = JText::_('JLIB_HTML_START');
         $Translations['prev'] = JText::_('JPREV');
         $Translations['next'] = JText::_('JNEXT');
         $Translations['end'] = JText::_('JLIB_HTML_END');
         if (strpos($URLPath, '?') === false) {
             $URLPath .= '?' . $u->getQuery();
         } else {
             $URLPath .= '&' . $u->getQuery();
         }
     } else {
         $Translations['all'] = JText::_('All');
         $Translations['start'] = JText::_('First');
         $Translations['prev'] = JText::_('Prev');
         $Translations['next'] = JText::_('Next');
         $Translations['end'] = JText::_('Last');
     }
     if (!empty($this->_additionalUrlParams)) {
         foreach ($this->_additionalUrlParams as $key => $value) {
             if (strpos($URLPath, '?') === false) {
                 $URLPath = '?' . $key . '=' . $value;
             } else {
                 $URLPath = '&' . $key . '=' . $value;
             }
         }
     }
     //echo '$URLPath='.$URLPath.'<br/>';
     require_once 'layoutrenderer.php';
     $URLPath = YoutubeGalleryLayoutRenderer::deleteURLQueryOption($URLPath, 'videoid');
     $URLPath = YoutubeGalleryLayoutRenderer::deleteURLQueryOption($URLPath, $this->prefix . 'ygstart');
     if (strpos($URLPath, '?') === false) {
         $computed_prefix = '?' . $this->prefix;
     } else {
         $computed_prefix = '&' . $this->prefix;
     }
     $URLPath = str_replace('&', '&amp;', $URLPath);
     //alteracao projeto portal padrao
     // $FullPath=$WebsiteRoot.$URLPath;
     $domain = 'http';
     if (@$_SERVER["HTTPS"] == "on") {
         $pageURL .= "s";
     }
     $domain .= "://";
     if (@$_SERVER["SERVER_PORT"] != "80") {
         $domain .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"];
     } else {
         $domain .= $_SERVER["SERVER_NAME"];
     }
     $FullPath = $domain . '/' . $URLPath;
     //fim alteracao projeto portal padrao
     $data->all = new JYGPaginationObject($Translations['all'], $this->prefix);
     if (!$this->_viewall) {
         $data->all->base = '0';
         $data->all->link = $FullPath;
     }
     // Set the start and previous data objects.
     //echo '$Translations[start]='.$Translations['start'].'<br/>';
     $data->start = new JYGPaginationObject($Translations['start'], $this->prefix);
     $data->previous = new JYGPaginationObject($Translations['prev'], $this->prefix);
     if ($this->get('pages.current') > 1) {
         $page = ($this->get('pages.current') - 2) * $this->limit;
         // Set the empty for removal from route
         $data->start->base = '0';
         $data->start->link = $FullPath;
         if ($this->AddAnchor) {
             $data->start->link .= $yg_anchor;
         }
         $data->previous->base = $page;
         $data->previous->link = $FullPath . $computed_prefix . 'ygstart=' . $page;
         if ($this->AddAnchor) {
             $data->previous->link .= $yg_anchor;
         }
     }
     // Set the next and end data objects.
     $data->next = new JYGPaginationObject($Translations['next'], $this->prefix);
     $data->end = new JYGPaginationObject($Translations['end'], $this->prefix);
     if ($this->get('pages.current') < $this->get('pages.total')) {
         $next = $this->get('pages.current') * $this->limit;
         $end = ($this->get('pages.total') - 1) * $this->limit;
         $data->next->base = $next;
         $data->next->link = $FullPath . $computed_prefix . 'ygstart=' . $next;
         if ($this->AddAnchor) {
             $data->next->link .= $yg_anchor;
         }
         $data->end->base = $end;
         $data->end->link = $FullPath . $computed_prefix . 'ygstart=' . $end;
         if ($this->AddAnchor) {
             $data->end->link .= $yg_anchor;
         }
     }
     $data->pages = array();
     $stop = $this->get('pages.stop');
     for ($i = $this->get('pages.ygstart'); $i <= $stop; $i++) {
         $offset = ($i - 1) * $this->limit;
         // Set the empty for removal from route
         //$offset = $offset == 0 ? '' : $offset;
         $data->pages[$i] = new JYGPaginationObject($i, $this->prefix);
         if ($i != $this->get('pages.current') || $this->_viewall) {
             $data->pages[$i]->base = $offset;
             if ($offset == 0) {
                 $data->pages[$i]->link = $FullPath;
             } else {
                 $data->pages[$i]->link = $FullPath . $computed_prefix . 'ygstart=' . $offset;
             }
         }
         if ($this->AddAnchor) {
             $data->pages[$i]->link .= $yg_anchor;
         }
     }
     return $data;
 }
 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('&nbsp;&nbsp;', $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>';
 }
Пример #12
0
 /**
  * setHost
  *
  * @param $host
  *
  * @return void
  */
 public function setHost($host)
 {
     $uri = new JURI($host);
     $this->host = $host = $uri->getHost() . $uri->getPath();
     $this->uri->setHost($host);
 }
Пример #13
0
	/**
	 * Returns the current host name
	 * @return string
	 */
	public static function get_host()
	{
		if(defined('AKEEBACLI'))
		{
			require_once JPATH_ROOT.DS.'libraries'.DS.'joomla'.DS.'environment'.DS.'uri.php';
			$url = AEPlatform::get_platform_configuration_option('siteurl','');
			$oURI = new JURI($url);
			return $oURI->getHost();
		}
		$uri =& JURI::getInstance();
		return $uri->getHost();
	}
Пример #14
0
 /**
  * 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();
     }
 }
Пример #15
0
 /**
  * Create and return the pagination data object.
  *
  * @return  object  Pagination data object.
  * @since   11.1
  */
 protected function _buildDataObject()
 {
     jimport('joomla.version');
     $version = new JVersion();
     $JoomlaVersionRelease = $version->RELEASE;
     $yg_anchor = '#youtubegallery';
     $data = new stdClass();
     $WebsiteRoot = '';
     if ($JoomlaVersionRelease >= 1.6) {
         $WebsiteRoot = JURI::base();
         $u = JURI::getInstance();
         $uri = $u->toString();
         $URLPath = $u->getPath();
         if ($WebsiteRoot[strlen($WebsiteRoot) - 1] != '/') {
             //Root must have slash / in the end
             $WebsiteRoot .= '/';
         }
         if ($URLPath[0] != '/') {
             //Root must have slash / in the end
             $URLPath = '/' . $URLPath;
         }
         $a = explode('/', $WebsiteRoot);
         $b = explode('/', $URLPath);
         $s = -1;
         $ca = count($a);
         for ($i = 0; $i < count($b) and $i < $ca - 3; $i++) {
             if ($a[$ca - 1 - $i] == $b[$i]) {
                 $s = $i;
             } else {
                 break;
             }
         }
         if ($s != -1) {
             $c = array();
             for ($i = $s + 1; $i < count($b); $i++) {
                 $c[] = $b[$i];
             }
             $URLPath = implode('/', $c);
         }
     } else {
         $juri = new JURI();
         $WebsiteRoot = $juri->getHost();
         $URLPath = $_SERVER['REQUEST_URI'];
         // example:  /index.php'
     }
     //good idea:
     //$uh=parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
     if ($WebsiteRoot[strlen($WebsiteRoot) - 1] != '/') {
         //Root must have slash / in the end
         $WebsiteRoot .= '/';
     }
     //the path must start without "/"
     if ($URLPath != '') {
         if ($URLPath[0] == '/') {
             $URLPath = substr($URLPath, 1);
         }
     }
     //check if the path already contains video alias
     //delete it if found.
     if (!(strpos(JPATH_COMPONENT, '/com_youtubegallery') === false)) {
         //youtube gallery component
         $s = explode('/', $URLPath);
         $sc = count($s);
         if ($sc >= 1) {
             $pair = explode('?', $s[$sc - 1]);
             $alias = str_replace('.html', '', $pair[0]);
             $alias = str_replace('.htm', '', $alias);
             $alias = str_replace('.php', '', $alias);
             if (YGPagination::CheckIfAliasExixst($alias)) {
                 if (isset($pair[1])) {
                     $s[$sc - 1] = $pair[1];
                 } else {
                     unset($s[$sc - 1]);
                     $URLPath = implode('/', $s);
                 }
             }
         }
     }
     //---------------------
     $Translations = array();
     if ($JoomlaVersionRelease >= 1.6) {
         $Translations['all'] = JText::_('JLIB_HTML_VIEW_ALL');
         $Translations['start'] = JText::_('JLIB_HTML_START');
         $Translations['prev'] = JText::_('JPREV');
         $Translations['next'] = JText::_('JNEXT');
         $Translations['end'] = JText::_('JLIB_HTML_END');
         $URLPath .= YGPagination::QuestionmarkOrAnd($URLPath) . $u->getQuery();
     } else {
         $Translations['all'] = JText::_('All');
         $Translations['start'] = JText::_('First');
         $Translations['prev'] = JText::_('Prev');
         $Translations['next'] = JText::_('Next');
         $Translations['end'] = JText::_('Last');
     }
     if (!empty($this->_additionalUrlParams)) {
         foreach ($this->_additionalUrlParams as $key => $value) {
             $URLPath .= YGPagination::QuestionmarkOrAnd($URLPath) . $key . '=' . $value;
         }
     }
     require_once 'layoutrenderer.php';
     $URLPath = YoutubeGalleryLayoutRenderer::deleteURLQueryOption($URLPath, 'videoid');
     $URLPath = YoutubeGalleryLayoutRenderer::deleteURLQueryOption($URLPath, $this->prefix . 'ygstart');
     $computed_prefix = YGPagination::QuestionmarkOrAnd($URLPath) . $this->prefix;
     $URLPath = str_replace('&', '&amp;', $URLPath);
     $FullPath = $WebsiteRoot . $URLPath;
     $data->all = new JYGPaginationObject($Translations['all'], $this->prefix);
     if (!$this->_viewall) {
         $data->all->base = '0';
         $data->all->link = $FullPath;
     }
     // Set the start and previous data objects.
     $data->start = new JYGPaginationObject($Translations['start'], $this->prefix);
     $data->previous = new JYGPaginationObject($Translations['prev'], $this->prefix);
     if ($this->get('pages.current') > 1) {
         $page = ($this->get('pages.current') - 2) * $this->limit;
         // Set the empty for removal from route
         $data->start->base = '0';
         $data->start->link = $FullPath;
         if ($this->AddAnchor) {
             $data->start->link .= $yg_anchor;
         }
         $data->previous->base = $page;
         $data->previous->link = $FullPath . $computed_prefix . 'ygstart=' . $page;
         if ($this->AddAnchor) {
             $data->previous->link .= $yg_anchor;
         }
     }
     // Set the next and end data objects.
     $data->next = new JYGPaginationObject($Translations['next'], $this->prefix);
     $data->end = new JYGPaginationObject($Translations['end'], $this->prefix);
     if ($this->get('pages.current') < $this->get('pages.total')) {
         $next = $this->get('pages.current') * $this->limit;
         $end = ($this->get('pages.total') - 1) * $this->limit;
         $data->next->base = $next;
         $data->next->link = $FullPath . $computed_prefix . 'ygstart=' . $next;
         if ($this->AddAnchor) {
             $data->next->link .= $yg_anchor;
         }
         $data->end->base = $end;
         $data->end->link = $FullPath . $computed_prefix . 'ygstart=' . $end;
         if ($this->AddAnchor) {
             $data->end->link .= $yg_anchor;
         }
     }
     $data->pages = array();
     $stop = $this->get('pages.stop');
     for ($i = $this->get('pages.ygstart'); $i <= $stop; $i++) {
         $offset = ($i - 1) * $this->limit;
         // Set the empty for removal from route
         //$offset = $offset == 0 ? '' : $offset;
         $data->pages[$i] = new JYGPaginationObject($i, $this->prefix);
         if ($i != $this->get('pages.current') || $this->_viewall) {
             $data->pages[$i]->base = $offset;
             if ($offset == 0) {
                 $data->pages[$i]->link = $FullPath;
             } else {
                 $data->pages[$i]->link = $FullPath . $computed_prefix . 'ygstart=' . $offset;
             }
         }
         if ($this->AddAnchor) {
             $data->pages[$i]->link .= $yg_anchor;
         }
     }
     return $data;
 }
Пример #16
0
 /**
  * Changes the links (src/href) of HTML
  * @return: String 
  */
 public function changeLinks($contents, $root_path = JPATH_ROOT, $base_uri = '')
 {
     /** change js links	**/
     $regex = '/src=(["\'])(.*?)\\1/';
     $count = preg_match_all($regex, $contents, $match);
     if ($count > 0) {
         $changes = $match[2];
         foreach ($changes as $change) {
             //remove url file not exists
             $uri = new JURI($change);
             if ($_SERVER['HTTP_HOST'] != $uri->getHost() && $uri->getHost() != '') {
                 $headers = @get_headers($change, 1);
                 if ($headers[0] == 'HTTP/1.1 404 Not Found') {
                     $contents = str_replace('src="' . $change . '"', 'src=""', $contents);
                 }
             }
         }
     }
     /** change href reference **/
     $regex = '/href=(["\'])(.*?)\\1/';
     $count = preg_match_all($regex, $contents, $match);
     if ($count > 0) {
         $changes = $match[2];
         foreach ($changes as $change) {
             //remove url file not exists
             $uri = new JURI($change);
             if ($_SERVER['HTTP_HOST'] != $uri->getHost() && $uri->getHost() != '') {
                 $headers = @get_headers($change, 1);
                 if ($headers[0] == 'HTTP/1.1 404 Not Found') {
                     $contents = str_replace('href="' . $change . '"', 'href=""', $contents);
                 }
             }
         }
     }
     /** change href reference **/
     $regex = '/action=(["\'])(.*?)\\1/';
     $count = preg_match_all($regex, $contents, $match);
     if ($count > 0) {
         $changes = $match[2];
         foreach ($changes as $change) {
             //remove url file not exists
             $uri = new JURI($change);
             if ($_SERVER['HTTP_HOST'] != $uri->getHost() && $uri->getHost() != '') {
                 $headers = @get_headers($change, 1);
                 if ($headers[0] == 'HTTP/1.1 404 Not Found') {
                     $contents = str_replace('action="' . $change . '"', 'action=""', $contents);
                 }
             }
         }
     }
     /** change links **/
     $doc = new DOMDocument();
     if (@$doc->loadhtml($contents)) {
         $xpath = new DOMXpath($doc);
         $uri = JURI::getInstance();
         foreach ($xpath->query('//html//a') as $eInput) {
             $href = $eInput->getAttribute('href');
             $uri = new JURI($href);
             if (JString::trim($href) != '#' && JString::trim($href) != '' && ($_SERVER['HTTP_HOST'] == $uri->getHost() || $uri->getHost() == '')) {
                 $extend_url = JSN_RENDER_PAGE_URL . base64_encode($href);
                 $eInput->setAttribute('href', $extend_url);
             } else {
                 $eInput->setAttribute('href', 'javascript:;');
             }
         }
     }
     /** SAVE HTML after changed **/
     return $doc->saveHTML();
 }
Пример #17
0
 /**
  * Returns the current host name
  * @return string
  */
 public function get_host()
 {
     require_once JPATH_ROOT . '/libraries/joomla/environment/uri.php';
     $url = AEPlatform::getInstance()->get_platform_configuration_option('siteurl', '');
     $oURI = new JURI($url);
     return $oURI->getHost();
 }
Пример #18
0
 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 . "&amp;media=" . $this->_image . "&amp;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;
 }