<commit_before><?php

/*
Serverboy Interchange
View manager

Copyright 2010 Serverboy Software; <NAME>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

class view_manager {
	
	public static $stack = array();
	public static $values = array();
	
	public static function set_value($name, $value) {
		self::$values[$name] = $value;
	}
	public static function get_value($name, $default='') {
		if(isset(self::$values[$name]))
			return self::$values[$name];
		return $default;
	}
	public static function add_view($name) {
		self::$stack[] = $name;
	}
	public static function render() {
		global $path, $session, $keyval; // For use in the views
		$file = array_shift(self::$stack);
		if(empty($file)) return '';
		if(!is_file('./views/' . $file . '.php')) {
			return "View '$file' could not be found.";
		}
		ob_start();
		require('./views/' . $file . '.php');
		return ob_get_clean();
	}
	public static function render_as_httpresponse() {
		return new HttpResponse(self::render());
	}
	public static function render_as_value($name) {
		self::$values[$name] = self::render();
	}
	public static function render_and_pipe($through) {
		$output = self::render();
		return pipe::through($data, $through);
	}
	public static function dump() {self::$stack = array();}
	
}<commit_msg>A better way to access the view manager.<commit_after><?php

/*
Serverboy Interchange
View manager

Copyright 2010 Serverboy Software; <NAME>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

*/

class views {
	
	public static $stack = array();
	public static $values = array();
	
	public static function set($name, $value) {
		self::$values[$name] = $value;
	}
	public static function get($name, $default='') {
		if(isset(self::$values[$name]))
			return self::$values[$name];
		return $default;
	}
	public static function add_view($name) {
		self::$stack[] = $name;
	}
	public static function render() {
		global $path, $session, $keyval; // For use in the views
		$file = array_shift(self::$stack);
		if(empty($file)) return '';
		if(!is_file('./views/' . $file . '.php')) {
			return "View '$file' could not be found.";
		}
		ob_start();
		require('./views/' . $file . '.php');
		return ob_get_clean();
	}
	public static function render_as_httpresponse() {
		return new HttpResponse(self::render());
	}
	public static function render_as_value($name) {
		self::$values[$name] = self::render();
	}
	public static function render_and_pipe($through) {
		$output = self::render();
		return pipe::through($data, $through);
	}
	public static function dump() {self::$stack = array();}
	
}

class view_manager extends views {
	public static function set_value($name, $value) {return self::set($name, $value);}
	public static function get_value($name, $default='') {return self::get($name, $default);}
}
{'fraction_non_alphanumeric': 0.13752350255170562, 'fraction_numerical': 0.0042976094547408005, 'mean_word_length': 4.608433734939759, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5344347', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1098, 'n_words': 391}