<commit_before><?php

namespace WebCMS;

/**
 * Description of Settings
 *
 * @author <NAME> <tomas.voslar at webcook.cz>
 */
class Settings {
		
	/* @var Array('sections' => array(0 => Setting, ...)) */
	private $settings;
	
	/* \Doctrine\ORM\EntityManager */
	private $em;
	
	/* \AdminModule\Language */
	private $language;
	
	const SECTION_BASIC = 'basic';
	
	const SECTION_IMAGE = 'image';
	
	const SECTION_EMAIL = 'email';
	
	public function __construct($em, $language){
		$this->em = $em;
		$this->language = $language;
	}
	
	/**
	 * Gets settings by key and section.
	 * @param String $key
	 * @param String $section
	 * @return String
	 * @throws Exception
	 */
	public function get($key, $section = 'basic', $type = 'text', $options = array()){
			
		// system settings
		if(array_key_exists($section, $this->settings)){
			if(array_key_exists($key, $this->settings[$section])){
				return $this->settings[$section][$key];
			}
		}
		
		return $this->save($key, $section, $type, $options);
	}
	
	/**
	 * 
	 * @param type $section
	 * @return type
	 * @throws Exception
	 */
	public function getSection($section){
		if(array_key_exists($section, $this->settings)){
			return $this->settings[$section];
		}
		
		return FALSE;
	}
	
	/**
	 * 
	 * @param String $key
	 * @param String $section
	 */
	private function save($key, $section, $type = 'text', $options = array()){
		$setting = new \AdminModule\Setting;
		$setting->setKey($key);
		$setting->setSection($section);
		$setting->setType($type);
		$setting->setValue('');
		$setting->setLanguage($this->language);
		$setting->setOptions($options);
		
		$this->em->persist($setting);
		$this->em->flush();
		
		return $setting;
	}
	
	public function getSettings() {
		return $this->settings;
	}

	public function setSettings($settings) {<commit_msg>Update Settings.php<commit_after><?php

namespace WebCMS;

/**
 * Description of Settings
 *
 * @author <NAME> <tomas.voslar at webcook.cz>
 */
class Settings {
		
	/* @var Array('sections' => array(0 => Setting, ...)) */
	private $settings;
	
	/* \Doctrine\ORM\EntityManager */
	private $em;
	
	/* \AdminModule\Language */
	private $language;
	
	const SECTION_BASIC = 'basic';
	
	const SECTION_IMAGE = 'image';
	
	const SECTION_EMAIL = 'email';
	
	public function __construct($em, $language){
		$this->em = $em;
		$this->language = $language;
	}
	
	/**
	 * Gets settings by key and section.
	 * @param String $key
	 * @param String $section
	 * @return String
	 * @throws Exception
	 */
	public function get($key, $section = 'basic', $type = null, $options = array()){
			
		// system settings
		if(array_key_exists($section, $this->settings)){
			if(array_key_exists($key, $this->settings[$section])){
				return $this->settings[$section][$key];
			}
		}
		
		return $this->save($key, $section, $type, $options);
	}
	
	/**
	 * 
	 * @param type $section
	 * @return type
	 * @throws Exception
	 */
	public function getSection($section){
		if(array_key_exists($section, $this->settings)){
			return $this->settings[$section];
		}
		
		return FALSE;
	}
	
	/**
	 * 
	 * @param String $key
	 * @param String $section
	 */
	private function save($key, $section, $type = null, $options = array()){
		$setting = new \AdminModule\Setting;
		$setting->setKey($key);
		$setting->setSection($section);
		$setting->setType($type);
		$setting->setValue('');
		$setting->setLanguage($this->language);
		$setting->setOptions($options);
		
		$this->em->persist($setting);
		$this->em->flush();
		
		return $setting;
	}
	
	public function getSettings() {
		return $this->settings;
	}

	public function setSettings($settings) {
{'fraction_non_alphanumeric': 0.17882808181315643, 'fraction_numerical': 0.000552791597567717, 'mean_word_length': 3.645699614890886, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 51, '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': '4300690', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1153, 'n_words': 263}