<commit_before><?php
/**
 * Abstract base for all elements
 *
 * @package platform.org.cashmusic
 * @author CASH Music
 * @link http://cashmusic.org/
 *
 * Copyright (c) 2013, CASH Music
 * Licensed under the GNU Lesser General Public License version 3.
 * See http://www.gnu.org/licenses/lgpl-3.0.html
 *
 * This file is generously sponsored by <NAME>
 *
 **/
abstract class ElementBase extends CASHData {
	protected $element_id, $status_uid, $template, $element_data, $original_request, $original_response, $options, $element, $appdata, $unlocked=false, $mustache=false;
	public $type = 'unknown';
	public $name = 'Unknown Element';

	abstract public function getData();

	public function __construct($element_id=0,$element=false,$status_uid=false,$original_request=false,$original_response=false) {
		// FYI: the element class takes an element object by reference because
		// ElementPlant needs to query the element_type anyway. So there didn't 
		// seem like much point in hitting the database twice every request.
		//
		// This is a note to myself as much as anyone else. Always feels silly.
		// -- jvd
		$this->element = $element;
		$this->element_id = $element_id;
		$this->original_request = $original_request;
		$this->original_response = $original_response;
		$this->status_uid = $status_uid;
		$this->template = 'default';
		if (isset($_REQUEST['element_id'])) {
			if ($_REQUEST['element_id'] != $this->element_id) {
				$this->status_uid = false;
			}
		}
		$this->options = $element['options'];
		if ($this->isUnlocked()) {
			$this->unlocked = true;
		}
		$this->element_data = array(
			'element_id' => $this->element_id,
			'element_type' => $this->type,
			'status_uid' => $this->status_uid,
			'user_id' => $this->element['user_id'],
			'www_url' => CASH_PUBLIC_URL,
			'api_url' => CASH_API_URL
		);
		$this->appdata = $this->getAppData();
		if (is_array($this->appdata)) {
			if (is_array($this->appdata['copy']['en'])) {
				foreach ($this->appdata['copy']['en'] as $key => $val) {
					$this->element_data['copy_' . $key] = $val;
				}
			}
		}
		error_log(print_r($this->element_data),true);
		if (is_array($this->options)) {
			$this->element_data = array_merge($this->element_data,$this->options);
		}
		if (file_exists(CASH_PLATFORM_ROOT . '/lib/mustache/Mustache.php')) {
			include_once(CASH_PLATFORM_ROOT . '/lib/mustache/Mustache.php');
			$this->mustache = new Mustache;
		}
		// check for an init() in the defined element. if it exists, call it
		if (method_exists($this,'init')) {<commit_msg>accidental print_r ...like a boss<commit_after><?php
/**
 * Abstract base for all elements
 *
 * @package platform.org.cashmusic
 * @author CASH Music
 * @link http://cashmusic.org/
 *
 * Copyright (c) 2013, CASH Music
 * Licensed under the GNU Lesser General Public License version 3.
 * See http://www.gnu.org/licenses/lgpl-3.0.html
 *
 * This file is generously sponsored by <NAME>
 *
 **/
abstract class ElementBase extends CASHData {
	protected $element_id, $status_uid, $template, $element_data, $original_request, $original_response, $options, $element, $appdata, $unlocked=false, $mustache=false;
	public $type = 'unknown';
	public $name = 'Unknown Element';

	abstract public function getData();

	public function __construct($element_id=0,$element=false,$status_uid=false,$original_request=false,$original_response=false) {
		// FYI: the element class takes an element object by reference because
		// ElementPlant needs to query the element_type anyway. So there didn't 
		// seem like much point in hitting the database twice every request.
		//
		// This is a note to myself as much as anyone else. Always feels silly.
		// -- jvd
		$this->element = $element;
		$this->element_id = $element_id;
		$this->original_request = $original_request;
		$this->original_response = $original_response;
		$this->status_uid = $status_uid;
		$this->template = 'default';
		if (isset($_REQUEST['element_id'])) {
			if ($_REQUEST['element_id'] != $this->element_id) {
				$this->status_uid = false;
			}
		}
		$this->options = $element['options'];
		if ($this->isUnlocked()) {
			$this->unlocked = true;
		}
		$this->element_data = array(
			'element_id' => $this->element_id,
			'element_type' => $this->type,
			'status_uid' => $this->status_uid,
			'user_id' => $this->element['user_id'],
			'www_url' => CASH_PUBLIC_URL,
			'api_url' => CASH_API_URL
		);
		$this->appdata = $this->getAppData();
		if (is_array($this->appdata)) {
			if (is_array($this->appdata['copy']['en'])) {
				foreach ($this->appdata['copy']['en'] as $key => $val) {
					$this->element_data['copy_' . $key] = $val;
				}
			}
		}
		if (is_array($this->options)) {
			$this->element_data = array_merge($this->element_data,$this->options);
		}
		if (file_exists(CASH_PLATFORM_ROOT . '/lib/mustache/Mustache.php')) {
			include_once(CASH_PLATFORM_ROOT . '/lib/mustache/Mustache.php');
			$this->mustache = new Mustache;
		}
		// check for an init() in the defined element. if it exists, call it
		if (method_exists($this,'init')) {
{'fraction_non_alphanumeric': 0.16136724960254373, 'fraction_numerical': 0.003179650238473768, 'mean_word_length': 4.220954356846473, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 74, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '357893', 'n_tokens_mistral': 1840, 'n_tokens_neox': 1674, 'n_words': 395}