File manager - Edit - /home/jardides/www/Jardi-design/old/components/com_sitemap/views/sitemap/view.html.php
Back
<?php /** * * @author SDIC SA * @package Sitemap * @version 2.0 * @copyright Copyright (C) 2015 SDIC SA * @license GNU GPLv2 * @link https://www.sdic.ch * */ // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import Joomla view library jimport('joomla.application.component.view'); class SiteMapViewSiteMap extends JViewLegacy { function display($tpl = null){ $app = JFactory::getApplication(); $user = JFactory::getUser(); //get url params $jinput = JFactory::getApplication()->input; $this->Itemid = $jinput->get('Itemid', '0'); //init model $model = $this->getModel(); //get params menu view $menuitem = $app->getMenu()->getItem($this->Itemid); //get global configuration $gconf_force_ssl = $app->get( 'force_ssl', 0 ); $gconf_force_ssl = (int)$gconf_force_ssl; //get url $url = substr(JURI::base(), 0, -1); //init var $this->result = ''; $xml_content = ''; $checkParams = false; if( isset($menuitem->params) ){ $params = $menuitem->params; $checkParams = true; //menutype $menuType = $params->get('menutype'); //display mode --> 0 => "standard" / 1 => "2 columns" / 2 => "3 columns" / 3 => "Full responsive" $this->display = $params->get('display'); //indentation sub menu --> 0 => "small" / 1 => "medium" / 2 => "big" $this->indentation = $params->get('indentation'); //display title component $this->displayTitle = $params->get('display_title'); //number of sub level displayed $this->display_level = $params->get('display_level'); //police size $this->display_police_size = $params->get('display_police_size'); //custom class link (tag a) $this->custom_class_link = $params->get('custom_class_link'); //custom class text (tag h) $this->custom_class_text = $params->get('custom_class_text'); //display border $this->display_border = $params->get('display_border'); //custom border color $this->border_color = $params->get('border_color'); //display hover background $this->display_hover_background = $params->get('display_hover_background'); //custom hover background $this->hover_background_color = $params->get('hover_background_color'); //generate xml $this->generate_xml = $params->get('generate_xml'); if( !is_array($menuType) || count($menuType) <= 0 ){ $checkParams = false; $this->result .= '<p style="text-align: center">'.JText::_('COM_SITEMAP_VIEW_NO_PARAMS_MENU').'</p>'; } if( $this->display != 0 && $this->display != 1 && $this->display != 2 && $this->display != 3 ){ $checkParams = false; $this->result .= '<p style="text-align: center">'.JText::_('COM_SITEMAP_VIEW_NO_PARAMS_DISPLAY').'</p>'; } }else{ $checkParams = false; $this->result .= '<p style="text-align: center">'.JText::_('COM_SITEMAP_VIEW_NO_PARAMS_MENU').'</p>'; } if( $checkParams ){ //use for all $counterParent = 0; $currentParent = 0; $currentGlobal = 0; //use for display on 2 or 3 columns $this->counterTot = 0; $counterByColumn = 0; $counterMargin = 0; $fillColumn2 = false; $fillColumn3 = false; //use for generated xml file $xml_content .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $xml_content .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n"; //pre pass on menu to know how much there are and calculate the number of menu by columns foreach( $menuType as $menu){ //get data $this->navs = $model->listNav( $menu ); foreach($this->navs as $key => $nav){ $this->counterTot++; if( $nav->level == 1 ){ $counterParent++; } } } if( $this->display == 1 ){ $counterByColumn = round( $this->counterTot / 2, 0 ); }else{ $counterByColumn = round( $this->counterTot / 3, 0 ); } $counterByColumn = (int)$counterByColumn; //calculate the margin of counter by coloumn (5%) -> use for layout 2 columns $counterMargin = round( 0.05 * $this->counterTot, 0); $counterMargin = (int)$counterMargin; foreach( $menuType as $menu){ //get data $this->navs = $model->listNav( $menu ); //use for "full responsive" view $current = 0; $parent = true; //default values $indentationFactor = 48; $this->width_lvl_1 = 5; $this->width_lvl_2 = 2 * $indentationFactor; $this->width_lvl_3 = 3 * $indentationFactor; $this->width_lvl_4 = 4 * $indentationFactor; //set value switch( $this->indentation ){ case 0: $indentationFactor = 24; break; case 1: $indentationFactor = 48; break; case 2: $indentationFactor = 64; break; } foreach($this->navs as $key => $nav){ //check ACL if( $nav->access > 1 && $user->id <= 0 ){ continue; } //check the level to display if( $this->display_level < $nav->level ){ continue; } $lev = $nav->level; $marginTopFirstLevel = false; switch ($lev){ case '1': $this->width_lvl_1 = 5; if( $this->display_police_size == 1 ){ $lev = 3; }elseif( $this->display_police_size == 3 ){ $lev = 1; }else{ $lev = 2; } $marginTopFirstLevel = true; $parent = true; $currentParent++; break; case '2': $this->width_lvl_2 = ($lev) * $indentationFactor; if( $this->display_police_size == 1 ){ $lev = 4; }elseif( $this->display_police_size == 3 ){ $lev = 2; }else{ $lev = 3; } $marginTopFirstLevel = false; $parent = false; break; case '3': $this->width_lvl_3 = ($lev) * $indentationFactor; if( $this->display_police_size == 1 ){ $lev = 5; }elseif( $this->display_police_size == 3 ){ $lev = 3; }else{ $lev = 4; } $marginTopFirstLevel = false; $parent = false; break; case '4': $this->width_lvl_4 = ($lev) * $indentationFactor; if( $this->display_police_size == 1 ){ $lev = 6; }elseif( $this->display_police_size == 3 ){ $lev = 4; }else{ $lev = 5; } $marginTopFirstLevel = false; $parent = false; break; default: break; } $name = $nav->title; if( $nav->type == 'url' ){ $include_xml = false; $link = $nav->link; }else{ $include_xml = true; $link = $nav->link.'&Itemid='.$nav->id; } if( $nav->type == 'alias' ){ //get menu alias id in menu params $params = json_decode($nav->params); if( isset($params->aliasoptions) ){ //get link of menu alias target $menuTargetAlias = $model->getNav( $params->aliasoptions ); //override link with the target menu alias if( isset($menuTargetAlias->link) ){ if( $nav->type == 'url' ){ $link = $menuTargetAlias->link; }else{ $link = $menuTargetAlias->link.'&Itemid='.$menuTargetAlias->id; } } } } switch( $this->display ){ case 1: //display 2 columns $cls = 'sitemap_wrapper_responsive'; if( $parent){ if( $current == 0){ //start first column $this->result .= '<div id="sitemap_wrapper_parent_'.$key.'" class="sitemap_wrapper_parent '.$cls.'">'; } //if( ($current >= $counterByColumn) && !$fillColumn2 ){ if( ( ($current >= ($counterByColumn - $counterMargin)) || ($current >= $counterByColumn) ) && !$fillColumn2 ){ $fillColumn2 = true; $this->result .= '</div>'; //add next column after limit by column (after next parent) $this->result .= '<div id="sitemap_wrapper_parent_'.$key.'" class="sitemap_wrapper_parent '.$cls.'">'; } } break; case 2: //display 3 columns $cls = 'sitemap_wrapper_responsive'; if( $parent){ if( $current == 0){ //start first column $this->result .= '<div id="sitemap_wrapper_parent_'.$key.'" class="sitemap_wrapper_parent '.$cls.'">'; } if( ($current >= $counterByColumn) && ($current <= ($counterByColumn * 2) ) && !$fillColumn2 && !$fillColumn3 ){ $fillColumn2 = true; $this->result .= '</div>'; //add next column after limit by column (after next parent) $this->result .= '<div id="sitemap_wrapper_parent_'.$key.'" class="sitemap_wrapper_parent '.$cls.'">'; } if( ($current >= ($counterByColumn * 2) ) && $fillColumn2 && !$fillColumn3 ){ $fillColumn3 = true; $this->result .= '</div>'; //add next column after limit by column (after next parent) $this->result .= '<div id="sitemap_wrapper_parent_'.$key.'" class="sitemap_wrapper_parent '.$cls.'">'; } } break; case 0: case 3: $cls = 'sitemap_wrapper_normal'; if( $this->display == 3){ $cls = 'sitemap_wrapper_responsive'; } if( $parent ){ if( $current !== 0 ){ $this->result .= '</div>'; } $this->result .= '<div id="sitemap_wrapper_parent_'.$key.'" class="sitemap_wrapper_parent '.$cls.'">'; } break; } $borderCls = ''; if( $this->display_border ){ $borderCls = 'sitemap_item_bodrer'; } switch( $nav->level ){ case 2: //start wrapper lvl 2 $this->result .= '<div id="sitemap_items_'.$key.'" class="sitemap_wrapper_lvl_2 sitemap_items sitemap_wrapper_indentation_lvl_2 '.$borderCls.'">'; break; case 3: //start wrapper lvl 3 $this->result .= '<div id="sitemap_items_'.$key.'" class="sitemap_wrapper_lvl_3 sitemap_items sitemap_wrapper_indentation_lvl_3 '.$borderCls.'">'; break; case 4: //start wrapper lvl 4 $this->result .= '<div id="sitemap_items_'.$key.'" class="sitemap_wrapper_lvl_4 sitemap_items sitemap_wrapper_indentation_lvl_4 '.$borderCls.'">'; break; case 1: default: //start wrapper lvl 1 $this->result .= '<div id="sitemap_items_'.$key.'" class="sitemap_wrapper_lvl_1 sitemap_items sitemap_wrapper_indentation_lvl_1 '.$borderCls.'">'; break; } //check params police size AND fix size if necessary (value 0) if( !$this->display_police_size ){ $lev = 4; } $clsLink = ''; if( !empty($this->custom_class_link) ){ $clsLink = 'class="'.$this->custom_class_link.' '.$this->custom_class_link.'_'.$lev.'"'; } $clsText = ''; if( !empty($this->custom_class_text) ){ $clsText = 'class="'.$this->custom_class_text.' '.$this->custom_class_text.'_'.$lev.'"'; } //view links $this->result .= '<a '.$clsLink.' href="'.JRoute::_($link).'" target="_self"><h'.$lev.' '.$clsText.'>'.$name.'</h'.$lev.'></a>'; //xml content + check ACL (list only public menus) if( $include_xml && $nav->access == 1 ){ $xml_content .= " <url>\n"; if( $gconf_force_ssl == 2 ){ $xml_content .= " <loc>".JRoute::_($link, true, true)."</loc>\n"; }else{ $xml_content .= " <loc>".$url.JRoute::_($link, true)."</loc>\n"; } $xml_content .= " </url>\n"; } $this->result .= "</div>"; $currentGlobal++; if( ($currentParent == $counterParent) && ($currentGlobal == $this->counterTot) ){ //close last parent $this->result .= '</div>'; } $current++; } } $xml_content .= "</urlset>\n"; if( $this->generate_xml ){ $file = JPATH_BASE.'/sitemap.xml'; $xfile = fopen ($file, "w"); if($xfile){ fwrite ($xfile, $xml_content); fclose ($xfile); }else{ //no rights to write } } } // Display the view parent::display($tpl); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.04 |
proxy
|
phpinfo
|
Settings