<commit_before><?php
/*
Controller for the Admin Themes page

Author: <NAME>
Url: http://denbeke.be
Date: March 2014
*/


namespace Controller\Admin {


	class Themes extends \Controller\Controller {

	
		public $pageName = 'themes';
		public $albums = array();
		public $notification = NULL;
		public $themes = [];
		
		
		public function __construct() {
			parent::__construct();
			$this->themeDir = __DIR__ . '/../../../admin/theme/';
			$this->theme = 'themes.php';
			$this->pageTitle = 'Themes - ' . SITE_TITLE;
					
			
			$themes = __DIR__ . '/../../../theme/*';			
			foreach (glob( $themes ) as $dir) {
				$theme_name = explode('/', $dir);
				$theme_name = $theme_name[sizeof($theme_name) - 1];
				
				$this->themes[$theme_name] = json_decode( file_get_contents($dir . '/theme.json') );
				$this->themes[$theme_name]->dir = $dir;
			}
			
		}
			
			
		public function GET($args) {
			
			if(isset($args[1])) {
			
				//if there is an action provided
				switch ($args[1]) {
				
					case "activate":
					case "activate/":
						if(isset($args[2])) {
							$this->activate($args[2]);
						}
						break;
				
				}
				
			}
			
		}
		
		
		
		private function activate($theme) {
			
			\Options::set(['theme' => $theme]);
			header('Location: ' . SITE_URL . 'admin/themes/');
			
			
		}
		
	
	}

}

?><commit_msg>Bugfix for admin themes: exception when empty theme folder -> needed to check for json theme file<commit_after><?php
/*
Controller for the Admin Themes page

Author: <NAME>
Url: http://denbeke.be
Date: March 2014
*/


namespace Controller\Admin {


	class Themes extends \Controller\Controller {

	
		public $pageName = 'themes';
		public $albums = array();
		public $notification = NULL;
		public $themes = [];
		
		
		public function __construct() {
			parent::__construct();
			$this->themeDir = __DIR__ . '/../../../admin/theme/';
			$this->theme = 'themes.php';
			$this->pageTitle = 'Themes - ' . SITE_TITLE;
					
			
			$themes = __DIR__ . '/../../../theme/*';			
			foreach (glob( $themes ) as $dir) {
				$theme_name = explode('/', $dir);
				$theme_name = $theme_name[sizeof($theme_name) - 1];
				
				/*
				if( !file_exists($dir . '/theme.json') ) {
					continue;
				}
				*/
				
				try {
					$this->themes[$theme_name] = json_decode( file_get_contents($dir . '/theme.json') );
					$this->themes[$theme_name]->dir = $dir;
				}
				catch (\exception $e) {
					continue;
				}
				
			}
			
		}
			
			
		public function GET($args) {
			
			if(isset($args[1])) {
			
				//if there is an action provided
				switch ($args[1]) {
				
					case "activate":
					case "activate/":
						if(isset($args[2])) {
							$this->activate($args[2]);
						}
						break;
				
				}
				
			}
			
		}
		
		
		
		private function activate($theme) {
			
			\Options::set(['theme' => $theme]);
			header('Location: ' . SITE_URL . 'admin/themes/');
			
			
		}
		
	
	}

}

?>
{'fraction_non_alphanumeric': 0.17826534110387385, 'fraction_numerical': 0.0061707233459033254, 'mean_word_length': 2.1890710382513663, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 24, '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': '5503317', 'n_tokens_mistral': 1338, 'n_tokens_neox': 956, 'n_words': 204}