public static function curPageURL($add_REQUEST_URI = true)
 {
     $pageURL = '';
     $pageURL .= 'http';
     if (isset($_SERVER["HTTPS"]) and $_SERVER["HTTPS"] == "on") {
         $pageURL .= "s";
     }
     $pageURL .= "://";
     if (isset($_SERVER["HTTPS"])) {
         if (isset($_SERVER["SERVER_PORT"]) and $_SERVER["SERVER_PORT"] != "80") {
             $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"];
         } else {
             $pageURL .= $_SERVER["SERVER_NAME"];
         }
     } else {
         $pageURL .= $_SERVER["SERVER_NAME"];
     }
     if ($add_REQUEST_URI) {
         //clean Facebook staff
         $uri = $_SERVER["REQUEST_URI"];
         if (!(strpos($uri, 'fb_action_ids=') === false)) {
             $uri = YoutubeGalleryLayoutRenderer::deleteURLQueryOption($uri, 'fb_action_ids');
             $uri = YoutubeGalleryLayoutRenderer::deleteURLQueryOption($uri, 'fb_action_types');
             $uri = YoutubeGalleryLayoutRenderer::deleteURLQueryOption($uri, 'fb_source');
             $uri = YoutubeGalleryLayoutRenderer::deleteURLQueryOption($uri, 'action_object_map');
             $uri = YoutubeGalleryLayoutRenderer::deleteURLQueryOption($uri, 'action_type_map');
             $uri = YoutubeGalleryLayoutRenderer::deleteURLQueryOption($uri, 'action_ref_map');
         }
         $pageURL .= $uri;
     }
     return $pageURL;
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }