<commit_before><?php

class Frontend extends ApiFrontend{
	/**
	 * stores currrent website model object
	 *
	 * @var Model_Epan
	 */
	public $current_website=null;
	/**
	 * Stores current page about to render
	 *
	 * @var Model_EpanPage
	 */
	public $current_page=null;
	/**
	 * Stores Website requested from GET[config['website_request_variable']]
	 *
	 * @var String
	 */
	public $website_requested=null;
	/**
	 * Stores Page requested from GET[config['page_request_variable']]
	 *
	 * @var String
	 */
	public $page_requested=null;
	/**
	 * Handels CMS mode,
	 * If set to true all editing features will be enabled in frontend side
	 *
	 * @var boolean
	 */
	public $edit_mode=false;

	// TODO Comments
	public $edit_template = false;

	/**
	 * $epan_plugins contains all plugins associated with this website/epan
	 * loaded in frontend
	 *
	 * @var array
	 */
	public $website_plugins=array();

	function init() {
		parent::init();

		// A lot of the functionality in Agile Toolkit requires jUI

		if ( !file_exists('config-default.php') ) {
			// Not installed and installation required
			// TODO : check security issues
			$config['url_postfix']='';
			$config['url_prefix']='?page=';

			$this->setConfig($config);
			$this->add( 'jUI' );

			// A lot of the functionality in Agile Toolkit requires jUI
			$this->js()
			->_load( 'atk4_univ' )
			->_load( 'ui.atk4_notify' )
			;
			
			$this->page = 'install';
		}else {
			// already installed connect to provided settings and go on
			$this->dbConnect();



			$this->requires( 'atk', '4.2.0' );


			$this->addLocation( 'templates', array( 'css'=>'default/css' ) );

			$this->addLocation( '.', array(
					'addons'=>array( 'epan-addons', 'epan-components', 'xavoc-addons' ) )
			);

			// This will add Epan Market Place Location
			$this->addLocation( 'epan-addons', array(
					'page'=>array( "." ),
				) );
			// This will add Epan Market Place Location
			$this->addLocation( 'epan-components', array(
					'page'=>array( "." ),
				) );
			// This will add some resources from atk4-addons, which would be located
			// in atk4-addons subdirectory.
			$this->addLocation( 'atk4-addons', array(
					'php'=>array(
						'mvc',
						'misc/lib',
					)
				) )
			->setParent( $this->pathfinder->base_location );

			$this->add( 'jUI' );
			$this->api->template->appendHTML('js_include','<script src="templates/js/jquery-migrate-1.2.1.min.js"></script>'."\n");
			/**
			 * TODO: wrap in a IF(page does not contains owner_ / branch_ / system_ )
			 * only then you need to get all this, as you are looking front of a website
			 * -----------------------------------------------------------------------
			 * Get the request from browser query string and set various Api variables like
			 * current_website, current_page, website_requested and page_requested
			 * Once set that can be accessed all CMS vise like
			 * $this->api->current_website
			 */
			if ( true /*page does not contain owner_ / branch_ or system_ */ ) {
				$site_parameter= $this->getConfig( 'url_site_parameter' );
				$page_parameter= $this->getConfig( 'url_page_parameter' );

				$this->stickyGET( $site_parameter );
				$this->stickyGET( $page_parameter );

				$this->website_requested = $this->getConfig( 'default_site' );
				/**
				 * $this->page_requested finds and gets the requested page
				 * Always required in both multi site mode and single site mode
				 *
				 * @var String
				 */
				$this->page_requested=trim( $_GET[$page_parameter], '/' )
					?  trim( $_GET[$page_parameter], '/' )
					: $this->getConfig( 'default_page' );

				if ( $this->isAjaxOutput() or $_GET['cut_page'] ) {
					// set page_requested to referrer page not the page requested by
					// ajax request
					$this->add( 'Controller_AjaxRequest' );

				}


				$this->add( 'Controller_EpanCMSApp' )->frontEnd();
				
				$this->current_website = $this->add( 'Model_Epan' )->tryLoadBy( 'name', $this->website_requested );
				if ( $this->current_website->loaded() ) {
					$this->current_page = $this->current_website->ref( 'EpanPage' )
					->addCondition( 'name', $this->page_requested )
					->tryLoadAny();
				}else {
					$this->exec_plugins( 'error404', $this->website_requested );
				}

				// MULTISITE CONTROLER
				// $this->load_plugins();
				// $this->add( 'Controller_EpanCMSApp' )->frontEnd();
				// if ( $this->current_website->loaded() )
				// 	$this->exec_plugins( 'website-loaded', $this->api->current_website );
				// if ( $this->current_page->loaded() )
				// 	$this->exec_plugins( 'website-page-loaded', $this->api->page_requested );

			}<commit_msg>Frontent updated to run properly in multi site mode<commit_after><?php

class Frontend extends ApiFrontend{
	/**
	 * stores currrent website model object
	 *
	 * @var Model_Epan
	 */
	public $current_website=null;
	/**
	 * Stores current page about to render
	 *
	 * @var Model_EpanPage
	 */
	public $current_page=null;
	/**
	 * Stores Website requested from GET[config['website_request_variable']]
	 *
	 * @var String
	 */
	public $website_requested=null;
	/**
	 * Stores Page requested from GET[config['page_request_variable']]
	 *
	 * @var String
	 */
	public $page_requested=null;
	/**
	 * Handels CMS mode,
	 * If set to true all editing features will be enabled in frontend side
	 *
	 * @var boolean
	 */
	public $edit_mode=false;

	// TODO Comments
	public $edit_template = false;

	/**
	 * $epan_plugins contains all plugins associated with this website/epan
	 * loaded in frontend
	 *
	 * @var array
	 */
	public $website_plugins=array();

	function init() {
		parent::init();

		// A lot of the functionality in Agile Toolkit requires jUI

		if ( !file_exists('config-default.php') ) {
			// Not installed and installation required
			// TODO : check security issues
			$config['url_postfix']='';
			$config['url_prefix']='?page=';

			$this->setConfig($config);
			$this->add( 'jUI' );

			// A lot of the functionality in Agile Toolkit requires jUI
			$this->js()
			->_load( 'atk4_univ' )
			->_load( 'ui.atk4_notify' )
			;
			
			$this->page = 'install';
		}else {
			// already installed connect to provided settings and go on
			$this->dbConnect();



			$this->requires( 'atk', '4.2.0' );


			$this->addLocation( 'templates', array( 'css'=>'default/css' ) );

			$this->addLocation( '.', array(
					'addons'=>array( 'epan-addons', 'epan-components', 'xavoc-addons' ) )
			);

			// This will add Epan Market Place Location
			$this->addLocation( 'epan-addons', array(
					'page'=>array( "." ),
				) );
			// This will add Epan Market Place Location
			$this->addLocation( 'epan-components', array(
					'page'=>array( "." ),
				) );
			// This will add some resources from atk4-addons, which would be located
			// in atk4-addons subdirectory.
			$this->addLocation( 'atk4-addons', array(
					'php'=>array(
						'mvc',
						'misc/lib',
					)
				) )
			->setParent( $this->pathfinder->base_location );

			$this->add( 'jUI' );
			$this->api->template->appendHTML('js_include','<script src="templates/js/jquery-migrate-1.2.1.min.js"></script>'."\n");
			/**
			 * TODO: wrap in a IF(page does not contains owner_ / branch_ / system_ )
			 * only then you need to get all this, as you are looking front of a website
			 * -----------------------------------------------------------------------
			 * Get the request from browser query string and set various Api variables like
			 * current_website, current_page, website_requested and page_requested
			 * Once set that can be accessed all CMS vise like
			 * $this->api->current_website
			 */
			if ( true /*page does not contain owner_ / branch_ or system_ */ ) {
				$site_parameter= $this->getConfig( 'url_site_parameter' );
				$page_parameter= $this->getConfig( 'url_page_parameter' );

				$this->stickyGET( $site_parameter );
				$this->stickyGET( $page_parameter );

				$this->website_requested = $this->getConfig( 'default_site' );
				/**
				 * $this->page_requested finds and gets the requested page
				 * Always required in both multi site mode and single site mode
				 *
				 * @var String
				 */
				$this->page_requested=trim( $_GET[$page_parameter], '/' )
					?  trim( $_GET[$page_parameter], '/' )
					: $this->getConfig( 'default_page' );

				if ( $this->isAjaxOutput() or $_GET['cut_page'] ) {
					// set page_requested to referrer page not the page requested by
					// ajax request
					$this->add( 'Controller_AjaxRequest' );

				}


				
				$this->current_website = $this->add( 'Model_Epan' )->tryLoadBy( 'name', $this->website_requested );
				if ( $this->current_website->loaded() ) {
					$this->current_page = $this->current_website->ref( 'EpanPage' )
					->addCondition( 'name', $this->page_requested )
					->tryLoadAny();
				}else {
					$this->exec_plugins( 'error404', $this->website_requested );
				}

				$this->add( 'Controller_EpanCMSApp' )->frontEnd();
				
				// MULTISITE CONTROLER
				// $this->load_plugins();
				// $this->add( 'Controller_EpanCMSApp' )->frontEnd();
				// if ( $this->current_website->loaded() )
				// 	$this->exec_plugins( 'website-loaded', $this->api->current_website );
				// if ( $this->current_page->loaded() )
				// 	$this->exec_plugins( 'website-page-loaded', $this->api->page_requested );

			}
{'fraction_non_alphanumeric': 0.16930874582120134, 'fraction_numerical': 0.0030195190337539094, 'mean_word_length': 2.9396771452846218, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 141, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '60726', 'n_tokens_mistral': 3571, 'n_tokens_neox': 2911, 'n_words': 730}