<?php
/*
 * Copyright (c) 2014-2015 Aimy Extensions, Lingua-Systems Software GmbH
 *
 * http://www.aimy-extensions.com/
 *
 * License: GNU GPLv2, see LICENSE.txt within distribution and/or
 *          http://www.aimy-extensions.com/software-license.html
 */
 defined( '_JEXEC' ) or die(); require_once( JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'rights.php' ); require_once( JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'message.php' ); class AimySitemapViewCrawl extends JViewLegacy { protected $allow_crawl = false; protected $allow_config = false; public function display( $tpl = null ) { if ( count( $errors = $this->get( 'Errors' ) ) ) { JError::raiseError( 500, implode( "\n", $errors ) ); return false; } $app = JFactory::getApplication(); if ( $app->isSSLConnection() ) { $msg = new AimySitemapMessageHelper(); $msg->notice( JText::_( 'AIMY_SM_CRAWL_HINT_SSL_ONLY' ) ); } if ( $this->get_config( $app, 'offline' ) ) { $msg = new AimySitemapMessageHelper(); $msg->error( JText::_( 'AIMY_SM_ERR_SITE_OFFLINE' ) ); $this->addToolbar(); return false; } if ( defined( 'JDEBUG' ) && JDEBUG ) { $msg = new AimySitemapMessageHelper(); $msg->notice( JText::sprintf( 'AIMY_SM_MSG_CRAWL_DEBUG_ENABLED', AimySitemapLogger::get_path() ) ); } $rights = AimySitemapRightsHelper::getRights(); $this->allow_crawl = $rights->get( 'aimysitemap.crawl' ); $this->allow_config = $rights->get( 'core.admin' ); $this->addToolbar(); if ( $this->allow_crawl ) { JFactory::getDocument()->addScript( JUri::root() . 'administrator/components/' . 'com_aimysitemap/helpers/crawl.js' . '?r=3.15.1' ); } else { $msg = new AimySitemapMessageHelper(); $msg->error( JText::_( 'JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN' ) ); } parent::display( $tpl ); } protected function addToolbar() { $bar = JToolBar::getInstance( 'toolbar' ); JToolBarHelper::title( JText::_( 'AIMY_SM_CRAWL' ), '' ); if ( $this->allow_crawl ) { JToolBarHelper::custom( 'crawl.crawl', 'tree-2', JText::_( 'AIMY_SM_CRAWL_START_DSC' ), JText::_( 'AIMY_SM_CRAWL_START_LBL' ), false ); JToolBarHelper::custom( 'crawl.abort', 'unpublish', JText::_( 'AIMY_SM_CRAWL_ABORT_DSC' ), JText::_( 'AIMY_SM_CRAWL_ABORT_LBL' ), false ); } if ( $this->allow_config ) { JToolBarHelper::preferences( 'com_aimysitemap' ); } } private function get_config( &$app, $key, $dflt = null ) { if ( version_compare( JVERSION, '3.3.0', '<' ) ) { return $app->getCfg( $key, $dflt ); } else { return $app->get( $key, $dflt ); } } } 
