<commit_before><?php
namespace Craft;

class Wistia_VideosFieldType extends BaseOptionsFieldType
{
	private $apiKey;

	public function __construct()
	{
		$this->apiKey = craft()
			->plugins
			->getPlugin('wistia')
			->getSettings()
			->apiKey;
	}

	/**
	 * Fieldtype name
	 *
	 * @return string
	 */
	public function getName()
	{
		return Craft::t('Wistia Videos');
	}

	/**
	 * Modify stored data
	 *
	 * @var $value Wistia video id from db
	 * @return string
	 */
	public function prepValue($value)
	{
		return $value;
	}

	/**
	 * Render fieldtype
	 *
	 * @return string
	 */
	public function getInputHtml($name, $value)
	{
		$params = [];
		$videos = craft()
			->wistia_apiConnect
			->getVideos($this->getSettings()->projects);

		if (is_array($videos)) {
			$template = 'wistia/fieldtype';
			$params = [
				'name'  => $name,
				'value' => $value,
				'videos' => $videos
			];
		} else {
			$template = 'wistia/fieldtype/errors';
			$params = [
				'errors' => [
					'error' => $videos
				]
			];
		}

		return craft()->templates->render($template, $params);
	}

	/**
	 * Define database column
	 *
	 * @return AttributeType::String
	 */
	public function defineContentAttribute()
	{
		return array(AttributeType::String);
	}

	/**
	 * Returns the label for the Options setting.
	 *
	 * @access protected
	 * @return string
	 */
	protected function getOptionsSettingsLabel()
	{
		return Craft::t('Wistia Video Options');
	}

	/**
	 * Define the settings
	 *
	 * @access protected
	 * @return array
	 */
	protected function defineSettings()
	{
		return array(
			'projects' => [
				AttributeType::Mixed,
				'default' => [
					'' => '--'
				]
			],
			'min' => [
				AttributeType::Number,
				'default' => 0
			],
			'max' => [
				AttributeType::Number
			]
		);
	}

	/**
	 * Display the field settings
	 *
	 * @return string
	 */
	public function getSettingsHtml()
	{
		$params = [];
		$projects = craft()->wistia_apiConnect->getProjects();

		if (is_array($projects)) {
			$template = 'wistia/fieldtype/settings';
			$params = [
				'settings' => $this->getSettings()
			];
		} else {
			$template = 'wistia/fieldtype/errors';
			$params = [
				'errors' => [
					'error' => $projects
				]
			];
		}

		return craft()->templates->render($template, $params);
	}

	/**
	 * Sanitize the settings
	 *
	 * @param array $settings
	 * @return array
	 */
	public function prepSettings($settings)
	{
		return $settings;
	}
}<commit_msg>Simplify fieldtype script<commit_after><?php
namespace Craft;

class Wistia_VideosFieldType extends BaseOptionsFieldType
{
	private $apiKey;

	public function __construct()
	{
		$this->apiKey = craft()
			->plugins
			->getPlugin('wistia')
			->getSettings()
			->apiKey;
	}

	/**
	 * Fieldtype name
	 *
	 * @return string
	 */
	public function getName()
	{
		return Craft::t('Wistia Videos');
	}

	/**
	 * Modify stored data
	 *
	 * @var $value Wistia video id from db
	 * @return string
	 */
	public function prepValue($value)
	{
		return $value;
	}

	/**
	 * Render fieldtype
	 *
	 * @return string
	 */
	public function getInputHtml($name, $value)
	{
		$videos = craft()
			->wistia_apiConnect
			->getVideos($this->getSettings()->projects);

		return craft()->templates->render('wistia/fieldtype', [
			'settings' => $this->getSettings(),
			'name'  => $name,
			'value' => $value,
			'videos' => $videos
		]);
	}

	/**
	 * Define database column
	 *
	 * @return AttributeType::String
	 */
	public function defineContentAttribute()
	{
		return array(AttributeType::String);
	}

	/**
	 * Returns the label for the Options setting.
	 *
	 * @access protected
	 * @return string
	 */
	protected function getOptionsSettingsLabel()
	{
		return Craft::t('Wistia Video Options');
	}

	/**
	 * Define the settings
	 *
	 * @access protected
	 * @return array
	 */
	protected function defineSettings()
	{
		return array(
			'projects' => [
				AttributeType::Mixed,
				'default' => [
					'' => '--'
				]
			],
			'min' => [
				AttributeType::Number,
				'default' => 0
			],
			'max' => AttributeType::Number
		);
	}

	/**
	 * Display the field settings
	 *
	 * @return string
	 */
	public function getSettingsHtml()
	{
		$projects = craft()->wistia_apiConnect->getProjects();

		return craft()->templates->render('wistia/fieldtype/settings', [
			'settings' => $this->getSettings()
		]);
	}

	/**
	 * Sanitize the settings
	 *
	 * @param array $settings
	 * @return array
	 */
	public function prepSettings($settings)
	{
		return $settings;
	}
}
{'fraction_non_alphanumeric': 0.16199376947040497, 'fraction_numerical': 0.0004450378282153983, 'mean_word_length': 2.9464442493415275, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, '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': '4900626', 'n_tokens_mistral': 1773, 'n_tokens_neox': 1478, 'n_words': 316}