<commit_before><?php 

include_once NWEB_ROOT.'/lib/core_blog.php';

abstract class ControllerBase{

	protected $settings;
	protected $configuration;
	protected $pageData;

	public function __construct(){

		$this->pageData = array();



	}

	/**
	 * Returns a map containing all of the controller 
	 * settings.
	 *
	 * @return a map of the class settings
	 */
	public function getConfigurables(){
		return $this->settings;
	}

	/**
	 * Reads an XML configuration file and sets the 
	 * class settings field
	 * 
	 * @param $path - the path to the config file
	 */
	public function readConfig( $path ){

		$confFile = $path;
	    $conf = array();
	    $conf['title'] = "Error";
	    $conf['catchline'] = "";
	    $conf['commentCode'] = "";
	    
	    
	    if ( file_exists($confFile) ){
	            $xml = simplexml_load_file( $path );
	            $conf = xmltoArray( $xml ); 
	            
	            
	    }

	    $this->settings = (array) RecArrayToObject($conf);
	    $this->settings['configFile'] = $path;

	    if ( !array_key_exists( 'template', $this->settings ) )
	    	$this->settings['template'] = NWEB_ROOT.'/config/template.d/generic_template.php';

	}


	/**
	 * Saves an xml configuration file. This is untested!
	 *
	 * @param $path - the path to the file to save
	 */
	public function saveConfig( $path ){

		$confFile = fopen( $path, 'w' );

		$xml = new SimpleXMLElement('<xml/>');
		$control = $xml->addChild('control');

		foreach ($this->settings as $key => $value) {

			$control->addChild($key, $value);


		}

		fwrite( $confFile, $xml->toXml() );
		fclose( $confFile );


	}

	/**
	 * Allows the class settings to be overwritten en-masse 
	 * externally by providing a new map.
	 *
	 * @param $map - the new settings array to use
	 */
	public function setConfig( $map ){
		$this->settings = $map;
	}

	/**
	 * Returns requested fields from the settings 
	 * array.
	 *
	 * @param $field - the name of the item to return
	 * @return the item
	 */
	public function __get( $field ){
                if ( $field == 'id'){
                    return get_called_class();
                } else {
		return $this->settings[$field];
                }
	}

	public function getPageData(){
		return $this->pageData;
	}

	/**
	 * Returns a list of pages that should be 
	 * available publicly. Used by the sitemap 
	 * generation system.
	 */
	public function getPageList(){
		return array();
	}

	/**
	 * Returns a list of posts (in order) that should be 
	 * available publicly. Used by the feed 
	 * generation system.
	 */
	public function getPostList(){
		return array();
	}
        
        public function unauthorized(){
            echo "403: You are not authorized to access this page.";
            die();
    }

    public function robotstxt(){
    	header("Content-Type: text/plain");
    	echo "User-agent: * \n";
    	echo "Allow: / \n";
    	echo "\n";
    	echo "Sitemap: " . Engine::get_option( 'site_domain' ) . '/?url=sitemaps/' . get_called_class() . "\n";
    	echo "Sitemap: " . Engine::get_option( 'site_domain' ) . '/?url=feeds/' . get_called_class();
    }

}

?><commit_msg>Fix controller interface sitemap generation<commit_after><?php 

include_once NWEB_ROOT.'/lib/core_blog.php';

use Naterweb\Engine\Configuration;
use Naterweb\Routing\Urls\UrlBuilder;

abstract class ControllerBase{

	protected $settings;
	protected $configuration;
	protected $pageData;

	public function __construct(){

		$this->pageData = array();



	}

	/**
	 * Returns a map containing all of the controller 
	 * settings.
	 *
	 * @return a map of the class settings
	 */
	public function getConfigurables(){
		return $this->settings;
	}

	/**
	 * Reads an XML configuration file and sets the 
	 * class settings field
	 * 
	 * @param $path - the path to the config file
	 */
	public function readConfig( $path ){

		$confFile = $path;
	    $conf = array();
	    $conf['title'] = "Error";
	    $conf['catchline'] = "";
	    $conf['commentCode'] = "";
	    
	    
	    if ( file_exists($confFile) ){
	            $xml = simplexml_load_file( $path );
	            $conf = xmltoArray( $xml ); 
	            
	            
	    }

	    $this->settings = (array) RecArrayToObject($conf);
	    $this->settings['configFile'] = $path;

	    if ( !array_key_exists( 'template', $this->settings ) )
	    	$this->settings['template'] = NWEB_ROOT.'/config/template.d/generic_template.php';

	}


	/**
	 * Saves an xml configuration file. This is untested!
	 *
	 * @param $path - the path to the file to save
	 */
	public function saveConfig( $path ){

		$confFile = fopen( $path, 'w' );

		$xml = new SimpleXMLElement('<xml/>');
		$control = $xml->addChild('control');

		foreach ($this->settings as $key => $value) {

			$control->addChild($key, $value);


		}

		fwrite( $confFile, $xml->toXml() );
		fclose( $confFile );


	}

	/**
	 * Allows the class settings to be overwritten en-masse 
	 * externally by providing a new map.
	 *
	 * @param $map - the new settings array to use
	 */
	public function setConfig( $map ){
		$this->settings = $map;
	}

	/**
	 * Returns requested fields from the settings 
	 * array.
	 *
	 * @param $field - the name of the item to return
	 * @return the item
	 */
	public function __get( $field ){
                if ( $field == 'id'){
                    return get_called_class();
                } else {
		return $this->settings[$field];
                }
	}

	public function getPageData(){
		return $this->pageData;
	}

	/**
	 * Returns a list of pages that should be 
	 * available publicly. Used by the sitemap 
	 * generation system.
	 */
	public function getPageList(){
		return array();
	}

	/**
	 * Returns a list of posts (in order) that should be 
	 * available publicly. Used by the feed 
	 * generation system.
	 */
	public function getPostList(){
		return array();
	}
        
        public function unauthorized(){
            echo "403: You are not authorized to access this page.";
            die();
    }

    public function robotstxt(){
    	header("Content-Type: text/plain");
    	echo "User-agent: * \n";
    	echo "Allow: / \n";
    	echo "\n";
	$feedUrl = new UrlBuilder(array(get_called_class()=>'feed'));
	$mapUrl = new UrlBuilder(array(get_called_class()=>'sitemap'));
    	echo "Sitemap: " . $mapUrl->build() . "\n";
    	echo "Sitemap: " . $feedUrl->build();
    }

}


{'fraction_non_alphanumeric': 0.14305949008498584, 'fraction_numerical': 0.0009442870632672333, 'mean_word_length': 2.5285952248750694, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1990793', 'n_tokens_mistral': 2154, 'n_tokens_neox': 1929, 'n_words': 564}