예제 #1
0
    /**
     * Control panel display
     *        	
     * @access public
     * @param string $tpl
     * @return void
     */
    public function display($tpl = null)
    {
        $doc = $this->document;
        $componentParams = $this->getModel()->getState('cparams');
        $base = JUri::root();
        $this->loadJQuery($doc);
        $this->loadBootstrap($doc);
        $doc->addStylesheet(JURI::root(true) . '/administrator/components/com_jmap/css/cpanel.css');
        $doc->addStylesheet(JURI::root(true) . '/administrator/components/com_jmap/css/jquery.fancybox.css');
        $doc->addScript(JURI::root(true) . '/administrator/components/com_jmap/js/chart.js');
        $doc->addScript(JURI::root(true) . '/administrator/components/com_jmap/js/cpanel.js');
        $doc->addScript(JURI::root(true) . '/administrator/components/com_jmap/js/analyzer.js');
        $doc->addScript(JURI::root(true) . '/administrator/components/com_jmap/js/metainfo.js');
        if ($componentParams->get('seostats_enabled', 1)) {
            $doc->addScript(JURI::root(true) . '/administrator/components/com_jmap/js/seostats.js');
        }
        if ($componentParams->get('enable_precaching', 0)) {
            $doc->addScript(JURI::root(true) . '/administrator/components/com_jmap/js/xmlprecaching.js');
        }
        $doc->addCustomTag('<script type="text/javascript" src="' . JURI::root(true) . '/administrator/components/com_jmap/js/jquery.fancybox.pack.js' . '"></script>');
        // Inject js translations
        $translations = array('COM_JMAP_ROBOTSPROGRESSTITLE', 'COM_JMAP_ROBOTSPROGRESSSUBTITLE', 'COM_JMAP_ROBOTSPROGRESSSUBTITLESUCCESS', 'COM_JMAP_ROBOTSPROGRESSSUBTITLEERROR', 'COM_JMAP_PRECACHING_TITLE', 'COM_JMAP_START_PRECACHING_PROCESS', 'COM_JMAP_PRECACHING_NO_DATASOURCES_FOUND', 'COM_JMAP_PRECACHING_PROCESS_RUNNING', 'COM_JMAP_PRECACHING_PROCESS_COMPLETED', 'COM_JMAP_PRECACHING_REPORT_DATASOURCE', 'COM_JMAP_PRECACHING_REPORT_DATASOURCE_TYPE', 'COM_JMAP_PRECACHING_REPORT_LINKS', 'COM_JMAP_PRECACHING_DATA_SOURCE_COMPLETED', 'COM_JMAP_PRECACHING_DATASOURCES_RETRIEVED', 'COM_JMAP_PRECACHING_PROCESS_FINALIZING', 'COM_JMAP_PRECACHING_INTERRUPT', 'COM_JMAP_PRECACHING_CACHED', 'COM_JMAP_PRECACHING_NOT_CACHED', 'COM_JMAP_PRECACHING_CLEARING', 'COM_JMAP_PRECACHING_CLEAR_CACHE', 'COM_JMAP_PUBLISHED_DATA_SOURCE_CHART', 'COM_JMAP_TOTAL_DATA_SOURCE_CHART', 'COM_JMAP_DATASETS_CHART', 'COM_JMAP_MENU_DATA_SOURCE_CHART', 'COM_JMAP_USER_DATA_SOURCE_CHART', 'COM_JMAP_ANALYZER_TITLE', 'COM_JMAP_ANALYZER_PROCESS_RUNNING', 'COM_JMAP_ANALYZER_STARTED_SITEMAP_GENERATION', 'COM_JMAP_ANALYZER_ERROR_STORING_FILE', 'COM_JMAP_ANALYZER_GENERATION_COMPLETE', 'COM_JMAP_METAINFO_TITLE', 'COM_JMAP_METAINFO_PROCESS_RUNNING', 'COM_JMAP_METAINFO_STARTED_SITEMAP_GENERATION', 'COM_JMAP_METAINFO_ERROR_STORING_FILE', 'COM_JMAP_METAINFO_GENERATION_COMPLETE', 'COM_JMAP_SEOSTATS_LOADING', 'COM_JMAP_ALEXA_GRAPH', 'COM_JMAP_NULL_RESPONSEDATA', 'COM_JMAP_ERROR_HTTP');
        $this->injectJsTranslations($translations, $doc);
        // Check for custom link domain
        $customDomain = trim($componentParams->get('custom_sitemap_domain', ''));
        $livesite = $customDomain ? rtrim($customDomain, '/') : substr_replace(JURI::root(), "", -1, 1);
        $user = JFactory::getUser();
        $lists = $this->get('Lists');
        $infoData = $this->get('Data');
        $doc->addScriptDeclaration('var jmapChartData = ' . json_encode($infoData));
        $doc->addScriptDeclaration("var jmap_baseURI='{$base}';");
        $doc->addScriptDeclaration("var jmap_linksRandom=" . $componentParams->get('sitemap_links_random', 0) . ";");
        $doc->addScriptDeclaration("var jmap_forceFormat=" . $componentParams->get('sitemap_links_forceformat', 0) . ";");
        // Assign SEF mode
        $this->siteRouter = JRouterSite::getInstance('site', array('mode' => JROUTER_MODE_SEF));
        $this->showSefLinks = $componentParams->get('sitemap_links_sef', false);
        $this->joomlaSefLinks = JFactory::getConfig()->get('sef', true);
        $this->siteItemid = null;
        if ($this->showSefLinks && $this->joomlaSefLinks) {
            $siteItemid = trim($componentParams->get('site_itemid', null));
            if ($siteItemid && is_numeric($siteItemid)) {
                $menuItem = JMenu::getInstance('site')->getItem((int) $siteItemid);
                if (isset($menuItem->alias)) {
                    $menuAlias = $menuItem->alias;
                    $doc->addScriptDeclaration("var jmap_sef_alias_links='{$menuAlias}';");
                    $this->siteItemid = '&Itemid=' . (int) $siteItemid;
                }
            }
        }
        // Buffer delle icons
        ob_start();
        $this->getIcon('index.php?option=com_jmap&task=sources.display', 'icon-48-data.png', JText::_('COM_JMAP_SITEMAP_SOURCES'), '', 'title="' . JText::_('COM_JMAP_SITEMAP_SOURCES') . '"');
        $this->getIcon('index.php?option=com_jmap&task=wizard.display', 'icon-48-wizard.png', JText::_('COM_JMAP_NEW_WIZARD_DATASOURCE'), '', 'title="' . JText::_('COM_JMAP_NEW_WIZARD_DATASOURCE') . '"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap', 'icon-48-html_sitemap.png', JText::_('COM_JMAP_SHOW_HTML_MAP'), 'target="_blank"', 'title="' . JText::_('COM_JMAP_SHOW_HTML_MAP') . '"', 'data-role="torefresh"');
        $this->getIcon('#xmlsitemap', 'icon-48-xml_sitemap.png', JText::_('COM_JMAP_SHOW_XML_MAP'), '', 'title="' . JText::_('COM_JMAP_SHOW_XML_MAP') . '"', 'class="fancybox"');
        $this->getIcon('#xmlsitemap_xslt', 'icon-48-xsl_sitemap.png', JText::_('COM_JMAP_SHOW_XML_MAP_XSLT'), '', 'title="' . JText::_('COM_JMAP_SHOW_XML_MAP_XSLT') . '"', 'class="fancybox"');
        $this->getIcon('#xmlsitemap_export', 'icon-48-xml_export.png', JText::_('COM_JMAP_EXPORT_XML_SITEMAP'), '', 'title="' . JText::_('COM_JMAP_EXPORT_XML_SITEMAP') . '"', 'class="fancybox"');
        $this->getIcon(substr_replace(JURI::root(), "", -1, 1) . '/index.php?option=com_jmap&task=sitemap.exportxml&format=xml', 'icon-48-analyze.png', JText::_('COM_JMAP_ANALYZE_MAP'), '', 'title="' . JText::_('COM_JMAP_ANALYZE_MAP') . '"', 'class="jmap_analyzer"');
        $this->getIcon(substr_replace(JURI::root(), "", -1, 1) . '/index.php?option=com_jmap&task=sitemap.exportxml&format=xml', 'icon-48-metainfo.png', JText::_('COM_JMAP_METAINFO'), '', 'title="' . JText::_('COM_JMAP_METAINFO') . '"', 'class="jmap_metainfo"');
        $this->getIcon('index.php?option=com_jmap&task=indexing.display', 'icon-48-indexing.png', JText::_('COM_JMAP_SITEMAP_INDEXING'), '', 'title="' . JText::_('COM_JMAP_SITEMAP_INDEXING') . '"');
        $this->getIcon('index.php?option=com_jmap&task=datasets.display', 'icon-48-datasets.png', JText::_('COM_JMAP_SITEMAP_DATASETS'), '', 'title="' . JText::_('COM_JMAP_SITEMAP_DATASETS') . '"');
        if ($user->authorise('core.edit', 'com_jmap')) {
            $this->getIcon('index.php?option=com_jmap&task=cpanel.editEntity', 'icon-48-robots.png', JText::_('COM_JMAP_ROBOTS_EDITOR'), '', 'title="' . JText::_('COM_JMAP_ROBOTS_EDITOR') . '"', 'class="fancybox_iframe"');
            $this->getIcon('index.php?option=com_jmap&task=htaccess.editEntity', 'icon-48-htaccess.png', JText::_('COM_JMAP_HTACCESS_EDITOR'), '', 'title="' . JText::_('COM_JMAP_HTACCESS_EDITOR') . '"', 'class="fancybox_iframe"');
        }
        $this->getIcon('index.php?option=com_jmap&task=pingomatic.display', 'icon-48-pingomatic.png', JText::_('COM_JMAP_PINGOMATIC_LINKS'), '', 'title="' . JText::_('COM_JMAP_PINGOMATIC_LINKS') . '"');
        $this->getIcon('#rssfeed', 'icon-48-rss-feed.png', JText::_('COM_JMAP_SHOW_RSS_FEED'), '', 'title="' . JText::_('COM_JMAP_SHOW_RSS_FEED') . '"', 'class="fancybox rss"');
        // Access check.
        if ($user->authorise('jmap.google', 'com_jmap')) {
            $this->getIcon('index.php?option=com_jmap&task=google.display', 'icon-48-google.png', JText::_('COM_JMAP_GOOGLE'), '', 'title="' . JText::_('COM_JMAP_GOOGLE_ANALYTICS') . '"');
        }
        // Access check.
        if ($user->authorise('core.admin', 'com_jmap')) {
            $this->getIcon('index.php?option=com_jmap&task=config.display', 'icon-48-config.png', JText::_('COM_JMAP_CONFIG'), '', 'title="' . JText::_('COM_JMAP_CONFIG') . '"');
        }
        $this->getIcon('http://storejextensions.org/jsitemap_professional_documentation.html', 'icon-48-help.png', JText::_('COM_JMAP_HELPTITLE'), '', 'title="' . JText::_('COM_JMAP_HELPTITLE') . '"');
        echo '<div style="display:none" id="xmlsitemap">';
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=xml', 'icon-48-xml_sitemap_standard.png', JText::_('COM_JMAP_SHOW_XML_STANDARD_MAP'), 'target="_blank"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=images', 'icon-48-xml_sitemap_images.png', JText::_('COM_JMAP_SHOW_XML_IMAGES_MAP'), 'target="_blank"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=gnews', 'icon-48-xml_sitemap_gnews.png', JText::_('COM_JMAP_SHOW_XML_GNEWS_MAP'), 'target="_blank"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=mobile', 'icon-48-xml_sitemap_mobile.png', JText::_('COM_JMAP_SHOW_XML_MOBILE_MAP'), 'target="_blank"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=videos', 'icon-48-xml_sitemap_videos.png', JText::_('COM_JMAP_SHOW_XML_VIDEOS_MAP'), 'target="_blank"');
        echo '</div>';
        echo '<div style="display:none" id="xmlsitemap_xslt">';
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=xml&xslt=1', 'icon-48-xml_sitemap_standard.png', JText::_('COM_JMAP_SHOW_XML_STANDARD_MAP'), 'target="_blank"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=images&xslt=1', 'icon-48-xml_sitemap_images.png', JText::_('COM_JMAP_SHOW_XML_IMAGES_MAP'), 'target="_blank"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=gnews&xslt=1', 'icon-48-xml_sitemap_gnews.png', JText::_('COM_JMAP_SHOW_XML_GNEWS_MAP'), 'target="_blank"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=mobile&xslt=1', 'icon-48-xml_sitemap_mobile.png', JText::_('COM_JMAP_SHOW_XML_MOBILE_MAP'), 'target="_blank"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=videos&xslt=1', 'icon-48-xml_sitemap_videos.png', JText::_('COM_JMAP_SHOW_XML_VIDEOS_MAP'), 'target="_blank"');
        echo '</div>';
        echo '<div style="display:none" id="xmlsitemap_export">';
        $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=xml', 'icon-48-xml_sitemap_standard.png', JText::_('COM_JMAP_EXPORT_XML_STANDARD_MAP'));
        $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=images', 'icon-48-xml_sitemap_images.png', JText::_('COM_JMAP_EXPORT_XML_IMAGES_MAP'));
        $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=gnews', 'icon-48-xml_sitemap_gnews.png', JText::_('COM_JMAP_EXPORT_XML_GNEWS_MAP'));
        $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=mobile', 'icon-48-xml_sitemap_mobile.png', JText::_('COM_JMAP_EXPORT_XML_MOBILE_MAP'));
        $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=videos', 'icon-48-xml_sitemap_videos.png', JText::_('COM_JMAP_EXPORT_XML_VIDEOS_MAP'));
        echo '</div>';
        echo '<div style="display:none" id="rssfeed">';
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=rss', 'icon-48-xml_sitemap.png', JText::_('COM_JMAP_SHOW_RSS_FEED'), 'target="_blank"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=rss&xslt=1', 'icon-48-xsl_sitemap.png', JText::_('COM_JMAP_SHOW_RSS_FEED_FORMATTED'), 'target="_blank"');
        $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=rss', 'icon-48-xml_export.png', JText::_('COM_JMAP_EXPORT_RSS_FEED'));
        echo '<label class="label label-primary">' . JText::_('COM_JMAP_RSS_FEED_LINK') . '</label>';
        if (!$this->showSefLinks || !$this->joomlaSefLinks) {
            ?>
		<input data-role="sitemap_links" class="sitemap_links" type="text" value="<?php 
            echo JFilterOutput::ampReplace($livesite . '/index.php?option=com_jmap&view=sitemap&format=rss');
            ?>
" />
		<?php 
        } else {
            ?>
		<input data-role="sitemap_links_sef" class="sitemap_links" type="text" data-valuenosef="<?php 
            echo JFilterOutput::ampReplace($livesite . '/index.php?option=com_jmap&view=sitemap&format=rss');
            ?>
" value="<?php 
            echo $livesite . preg_replace('/(\\/[A-Za-z0-9_-~]*)*\\/administrator\\//i', '/', $this->siteRouter->build('index.php?option=com_jmap&view=sitemap&format=rss' . $this->siteItemid));
            ?>
"/>
		<?php 
        }
        echo '</div>';
        $contents = ob_get_clean();
        // Assign reference variables
        $this->icons = $contents;
        $this->livesite = $livesite;
        $this->componentParams = $componentParams;
        $this->infodata = $infoData;
        $this->lists = $lists;
        $this->updatesData = $this->getModel()->getUpdates($this->get('httpclient'));
        $this->currentVersion = strval(simplexml_load_file(JPATH_COMPONENT_ADMINISTRATOR . '/jmap.xml')->version);
        // Aggiunta toolbar
        $this->addDisplayToolbar();
        // Output del template
        parent::display();
    }
예제 #2
0
 /**
  * Control panel display
  *        	
  * @access public
  * @param string $tpl
  * @return void
  */
 public function display($tpl = null)
 {
     $doc = $this->document;
     $componentParams = $this->getModel()->getState('cparams');
     $this->loadJQuery($doc);
     $this->loadBootstrap($doc);
     $doc->addStylesheet(JURI::root(true) . '/administrator/components/com_jmap/css/cpanel.css');
     $doc->addStylesheet(JURI::root(true) . '/administrator/components/com_jmap/css/jquery.fancybox.css');
     $doc->addScript(JURI::root(true) . '/administrator/components/com_jmap/js/chart.js');
     $doc->addScript(JURI::root(true) . '/administrator/components/com_jmap/js/cpanel.js');
     $doc->addScript(JURI::root(true) . '/administrator/components/com_jmap/js/analyzer.js');
     if ($componentParams->get('enable_precaching', 0)) {
         $doc->addScript(JURI::root(true) . '/administrator/components/com_jmap/js/xmlprecaching.js');
     }
     $doc->addCustomTag('<script type="text/javascript" src="' . JURI::root(true) . '/administrator/components/com_jmap/js/jquery.fancybox.pack.js' . '"></script>');
     // Inject js translations
     $translations = array('COM_JMAP_ROBOTSPROGRESSTITLE', 'COM_JMAP_ROBOTSPROGRESSSUBTITLE', 'COM_JMAP_ROBOTSPROGRESSSUBTITLESUCCESS', 'COM_JMAP_ROBOTSPROGRESSSUBTITLEERROR', 'COM_JMAP_PRECACHING_TITLE', 'COM_JMAP_START_PRECACHING_PROCESS', 'COM_JMAP_PRECACHING_NO_DATASOURCES_FOUND', 'COM_JMAP_PRECACHING_PROCESS_RUNNING', 'COM_JMAP_PRECACHING_PROCESS_COMPLETED', 'COM_JMAP_PRECACHING_REPORT_DATASOURCE', 'COM_JMAP_PRECACHING_REPORT_DATASOURCE_TYPE', 'COM_JMAP_PRECACHING_REPORT_LINKS', 'COM_JMAP_PRECACHING_DATA_SOURCE_COMPLETED', 'COM_JMAP_PRECACHING_DATASOURCES_RETRIEVED', 'COM_JMAP_PRECACHING_PROCESS_FINALIZING', 'COM_JMAP_PRECACHING_INTERRUPT', 'COM_JMAP_PRECACHING_CACHED', 'COM_JMAP_PRECACHING_NOT_CACHED', 'COM_JMAP_PRECACHING_CLEARING', 'COM_JMAP_PRECACHING_CLEAR_CACHE', 'COM_JMAP_PUBLISHED_DATA_SOURCE_CHART', 'COM_JMAP_TOTAL_DATA_SOURCE_CHART', 'COM_JMAP_MENU_DATA_SOURCE_CHART', 'COM_JMAP_USER_DATA_SOURCE_CHART', 'COM_JMAP_ANALYZER_TITLE', 'COM_JMAP_ANALYZER_PROCESS_RUNNING', 'COM_JMAP_ANALYZER_STARTED_SITEMAP_GENERATION', 'COM_JMAP_ANALYZER_ERROR_STORING_FILE', 'COM_JMAP_ANALYZER_GENERATION_COMPLETE');
     $this->injectJsTranslations($translations, $doc);
     $livesite = substr_replace(JURI::root(), "", -1, 1);
     $user = JFactory::getUser();
     $lists = $this->get('Lists');
     $infoData = $this->get('Data');
     $doc->addScriptDeclaration('var jmapChartData = ' . json_encode($infoData));
     // Buffer delle icons
     ob_start();
     $this->getIcon('index.php?option=com_jmap&task=sources.display', 'icon-48-data.png', JText::_('COM_JMAP_SITEMAP_SOURCES'), '', 'title="' . JText::_('COM_JMAP_SITEMAP_SOURCES') . '"');
     $this->getIcon('index.php?option=com_jmap&task=wizard.display', 'icon-48-wizard.png', JText::_('COM_JMAP_NEW_WIZARD_DATASOURCE'), '', 'title="' . JText::_('COM_JMAP_NEW_WIZARD_DATASOURCE') . '"');
     $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap', 'icon-48-html_sitemap.png', JText::_('COM_JMAP_SHOW_HTML_MAP'), 'target="_blank"', 'title="' . JText::_('COM_JMAP_SHOW_HTML_MAP') . '"', 'data-role="torefresh"');
     $this->getIcon('#xmlsitemap', 'icon-48-xml_sitemap.png', JText::_('COM_JMAP_SHOW_XML_MAP'), '', 'title="' . JText::_('COM_JMAP_SHOW_XML_MAP') . '"', 'class="fancybox"');
     $this->getIcon('#xmlsitemap_xslt', 'icon-48-xsl_sitemap.png', JText::_('COM_JMAP_SHOW_XML_MAP_XSLT'), '', 'title="' . JText::_('COM_JMAP_SHOW_XML_MAP_XSLT') . '"', 'class="fancybox"');
     $this->getIcon('#xmlsitemap_export', 'icon-48-xml_export.png', JText::_('COM_JMAP_EXPORT_XML_SITEMAP'), '', 'title="' . JText::_('COM_JMAP_EXPORT_XML_SITEMAP') . '"', 'class="fancybox"');
     $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=xml', 'icon-48-analyze.png', JText::_('COM_JMAP_ANALYZE_MAP'), '', 'title="' . JText::_('COM_JMAP_ANALYZE_MAP') . '"', 'class="jmap_analyzer"');
     if ($user->authorise('core.edit', 'com_jmap')) {
         $this->getIcon('index.php?option=com_jmap&task=cpanel.editEntity', 'icon-48-robots.png', JText::_('COM_JMAP_ROBOTS_EDITOR'), '', 'title="' . JText::_('COM_JMAP_ROBOTS_EDITOR') . '"', 'class="fancybox_iframe"');
     }
     $this->getIcon('index.php?option=com_jmap&task=pingomatic.display', 'icon-48-pingomatic.png', JText::_('COM_JMAP_PINGOMATIC_LINKS'), '', 'title="' . JText::_('COM_JMAP_PINGOMATIC_LINKS') . '"');
     // Access check.
     if ($user->authorise('core.admin', 'com_jmap')) {
         $this->getIcon('index.php?option=com_jmap&task=config.display', 'icon-48-config.png', JText::_('COM_JMAP_CONFIG'), '', 'title="' . JText::_('COM_JMAP_CONFIG') . '"');
     }
     $this->getIcon('http://storejextensions.org/jsitemap_professional_documentation.html', 'icon-48-help.png', JText::_('COM_JMAP_HELPTITLE'), '', 'title="' . JText::_('COM_JMAP_HELPTITLE') . '"');
     echo '<div style="display:none" id="xmlsitemap">';
     $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=xml', 'icon-48-xml_sitemap_standard.png', JText::_('COM_JMAP_SHOW_XML_STANDARD_MAP'), 'target="_blank"');
     $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=images', 'icon-48-xml_sitemap_images.png', JText::_('COM_JMAP_SHOW_XML_IMAGES_MAP'), 'target="_blank"');
     $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=gnews', 'icon-48-xml_sitemap_gnews.png', JText::_('COM_JMAP_SHOW_XML_GNEWS_MAP'), 'target="_blank"');
     $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=mobile', 'icon-48-xml_sitemap_mobile.png', JText::_('COM_JMAP_SHOW_XML_MOBILE_MAP'), 'target="_blank"');
     echo '</div>';
     echo '<div style="display:none" id="xmlsitemap_xslt">';
     $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=xml&xslt=1', 'icon-48-xml_sitemap_standard.png', JText::_('COM_JMAP_SHOW_XML_STANDARD_MAP'), 'target="_blank"');
     $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=images&xslt=1', 'icon-48-xml_sitemap_images.png', JText::_('COM_JMAP_SHOW_XML_IMAGES_MAP'), 'target="_blank"');
     $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=gnews&xslt=1', 'icon-48-xml_sitemap_gnews.png', JText::_('COM_JMAP_SHOW_XML_GNEWS_MAP'), 'target="_blank"');
     $this->getIcon($livesite . '/index.php?option=com_jmap&view=sitemap&format=mobile&xslt=1', 'icon-48-xml_sitemap_mobile.png', JText::_('COM_JMAP_SHOW_XML_MOBILE_MAP'), 'target="_blank"');
     echo '</div>';
     echo '<div style="display:none" id="xmlsitemap_export">';
     $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=xml', 'icon-48-xml_sitemap_standard.png', JText::_('COM_JMAP_EXPORT_XML_STANDARD_MAP'));
     $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=images', 'icon-48-xml_sitemap_images.png', JText::_('COM_JMAP_EXPORT_XML_IMAGES_MAP'));
     $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=gnews', 'icon-48-xml_sitemap_gnews.png', JText::_('COM_JMAP_EXPORT_XML_GNEWS_MAP'));
     $this->getIcon($livesite . '/index.php?option=com_jmap&task=sitemap.exportxml&format=mobile', 'icon-48-xml_sitemap_mobile.png', JText::_('COM_JMAP_EXPORT_XML_MOBILE_MAP'));
     echo '</div>';
     $contents = ob_get_clean();
     // Assign reference variables
     $this->icons = $contents;
     $this->livesite = $livesite;
     $this->componentParams = $componentParams;
     $this->infodata = $infoData;
     $this->lists = $lists;
     $this->updatesData = $this->getModel()->getUpdates($this->get('httpclient'));
     $this->siteRouter = JRouterSite::getInstance('site', array('mode' => JROUTER_MODE_SEF));
     $this->showSefLinks = $this->componentParams->get('sitemap_links_sef', false);
     $this->joomlaSefLinks = JFactory::getConfig()->get('sef', true);
     $this->currentVersion = strval(simplexml_load_file(JPATH_COMPONENT_ADMINISTRATOR . '/jmap.xml')->version);
     // Aggiunta toolbar
     $this->addDisplayToolbar();
     // Output del template
     parent::display();
 }
예제 #3
0
 /**
  * Route save single article to the corresponding SEF link
  *
  * @access private
  * @return string
  */
 private function routeArticleToSefMenu($articleID, $catID, $language, $article)
 {
     // Try to route the article to a single article menu item view
     $helperRouteClass = $this->context['class'];
     $classMethod = $this->context['method'];
     // Route helper native by component, com_content, com_k2
     if (!isset($this->context['routing'])) {
         $articleHelperRoute = $helperRouteClass::$classMethod($articleID, $catID, $language);
     } else {
         // Route helper universal JSitemap, com_zoo
         $articleHelperRoute = $helperRouteClass::$classMethod($article->option, $article->view, $article->id, $article->catid, null);
         if ($articleHelperRoute) {
             $articleHelperRoute = '?Itemid=' . $articleHelperRoute;
         }
     }
     // Extract Itemid from the helper routed URL
     $extractedItemid = preg_match('/Itemid=\\d+/i', $articleHelperRoute, $result);
     if (isset($result[0])) {
         // Get uri instance avoidng subdomains already included in the routing chunks
         $uriInstance = JUri::getInstance();
         $resourceLiveSite = rtrim($uriInstance->getScheme() . '://' . $uriInstance->getHost(), '/');
         $extractedItemid = $result[0];
         $siteRouter = JRouterSite::getInstance('site', array('mode' => JROUTER_MODE_SEF));
         $articleMenuRouted = $siteRouter->build('?' . $extractedItemid)->toString();
         // Check if multilanguage is enabled
         if (JMapLanguageMultilang::isEnabled()) {
             if ($language != '*') {
                 // New language manager instance
                 $languageManager = JMapLanguageMultilang::getInstance($language);
             } else {
                 // Get the default language tag
                 // New language manager instance
                 $languageManager = JMapLanguageMultilang::getInstance();
             }
             // Extract the language tag
             $localeTag = $languageManager->getLocale();
             $sefTag = $localeTag[4];
             $articleMenuRouted = str_replace('/administrator', '/' . $sefTag, $articleMenuRouted);
         } else {
             $articleMenuRouted = str_replace('/administrator', '', $articleMenuRouted);
         }
         $articleMenuRouted = preg_match('/http/i', $articleMenuRouted) ? $articleMenuRouted : $resourceLiveSite . '/' . ltrim($articleMenuRouted, '/');
         return $articleMenuRouted;
     } else {
         // Check if routing is valid otherwise throw exception
         throw new RuntimeException(JText::_('COM_JMAP_AUTOPING_ERROR_NOSEFROUTE_FOUND'));
     }
 }
예제 #4
0
 /**
  * Main get data method
  *
  * @access public
  * @return Object[]
  */
 public function getData()
 {
     // Load data from XML file, parse it to load records
     $cachedSitemapFilePath = JPATH_COMPONENT_ADMINISTRATOR . '/cache/analyzer/';
     // Has sitemap some vars such as lang or Itemid?
     $sitemapLang = $this->getState('sitemaplang', '');
     $sitemapLinksLang = $sitemapLang ? $sitemapLang . '/' : '';
     $sitemapLang = $sitemapLang ? '_' . $sitemapLang : '';
     $sitemapDataset = $this->getState('sitemapdataset', '');
     $sitemapDataset = $sitemapDataset ? '_dataset' . (int) $sitemapDataset : '';
     $sitemapItemid = $this->getState('sitemapitemid', '');
     $sitemapItemid = $sitemapItemid ? '_menuid' . (int) $sitemapItemid : '';
     // Final name
     $cachedSitemapFilename = 'sitemap_xml' . $sitemapLang . $sitemapDataset . $sitemapItemid . '.xml';
     // Start processing
     try {
         // Now check if the file correctly exists
         if (JFile::exists($cachedSitemapFilePath . $cachedSitemapFilename)) {
             $loadedSitemapXML = simplexml_load_file($cachedSitemapFilePath . $cachedSitemapFilename);
         } else {
             throw new JMapException(JText::sprintf('COM_JMAP_ANALYZER_NOCACHED_FILE_EXISTS', $this->_db->getErrorMsg()), 'error');
         }
         // Execute HTTP request and associate HTTP response code with each record links
         $httpClient = new JMapHttp();
         if ($loadedSitemapXML->url->count()) {
             // Manage splice pagination here for the XML records
             $convertedIteratorToArray = iterator_to_array($loadedSitemapXML->url, false);
             // Store number of records for pagination
             $this->recordsNumber = count($convertedIteratorToArray);
             // Execute pagination splicing if any limit is set
             $limit = $this->getState('limit');
             if ($limit) {
                 $loadedSitemapXML = array_splice($convertedIteratorToArray, $this->getState('limitstart'), $this->getState('limit'));
             } else {
                 $loadedSitemapXML = $convertedIteratorToArray;
             }
             // Now start the Analyzer
             $siteRouter = JRouterSite::getInstance('site', array('mode' => JROUTER_MODE_SEF));
             if (version_compare(JVERSION, '3.4', '>=')) {
                 JApplicationCms::getInstance('site')->loadLanguage();
             }
             $headers = array('Accept' => 'text/html', 'User-Agent' => 'Googlebot-Image/1.0');
             foreach ($loadedSitemapXML as $url) {
                 $httpResponse = $httpClient->get($url->loc, $headers);
                 $url->httpstatus = $httpResponse->code;
                 // Find informations about the link, component and menu itemid if any, need a workaround to parse correctly from backend
                 $baseAdmin = JURI::base();
                 $baseSite = str_replace('/administrator', '', $baseAdmin);
                 $fakedUrl = str_replace($baseSite, $baseAdmin, $url->loc);
                 $fakedUrl = str_replace($sitemapLinksLang, '', $fakedUrl);
                 // Now instantiate and parse the faked url from backend, replacing the uri base it will be = site
                 $uriObject = JURI::getInstance((string) $fakedUrl);
                 $parseUri = $siteRouter->parse($uriObject);
                 // Now augment the object to show informations
                 $url->component = isset($parseUri['option']) ? $parseUri['option'] : JText::_('COM_JMAP_ANALYZER_NOINFO');
                 $url->menuId = isset($parseUri['Itemid']) ? $parseUri['Itemid'] : JText::_('COM_JMAP_ANALYZER_NOINFO');
                 $url->menuTitle = JText::_('COM_JMAP_ANALYZER_NOINFO');
                 // Translate human menu
                 if (isset($parseUri['Itemid'])) {
                     $query = "SELECT" . $this->_db->quoteName('title') . "\n FROM #__menu" . "\n WHERE " . $this->_db->quoteName('id') . " = " . (int) $parseUri['Itemid'];
                     $menuTitle = $this->_db->setQuery($query)->loadResult();
                     $url->menuTitle = $menuTitle;
                 }
             }
             // Perform array sorting if any
             $order = $this->getState('order', null);
             $jmapAnalyzerOrderDir = $this->getState('order_dir', 'asc');
             if ($order == 'httpstatus') {
                 function cmpAsc($a, $b)
                 {
                     return (int) $a->httpstatus < (int) $b->httpstatus ? -1 : 1;
                 }
                 function cmpDesc($a, $b)
                 {
                     return (int) $a->httpstatus > (int) $b->httpstatus ? -1 : 1;
                 }
                 $callbackName = $jmapAnalyzerOrderDir == 'asc' ? 'cmpAsc' : 'cmpDesc';
                 usort($loadedSitemapXML, $callbackName);
             }
             if ($order == 'link') {
                 function cmpAsc($a, $b)
                 {
                     return strcmp($a->loc, $b->loc);
                 }
                 function cmpDesc($a, $b)
                 {
                     return strcmp($b->loc, $a->loc);
                 }
                 $callbackName = $jmapAnalyzerOrderDir == 'asc' ? 'cmpAsc' : 'cmpDesc';
                 usort($loadedSitemapXML, $callbackName);
             }
         } else {
             throw new JMapException(JText::sprintf('COM_JMAP_ANALYZER_EMPTY_SITEMAP', $this->_db->getErrorMsg()), 'notice');
         }
     } catch (JMapException $e) {
         $this->app->enqueueMessage($e->getMessage(), $e->getErrorLevel());
         $loadedSitemapXML = array();
     } catch (Exception $e) {
         $jmapException = new JMapException($e->getMessage(), 'error');
         $this->app->enqueueMessage($jmapException->getMessage(), $jmapException->getErrorLevel());
         $loadedSitemapXML = array();
     }
     return $loadedSitemapXML;
 }