<commit_before><?php

/**
 * Defines the SiteSprocketProductOption data type, representing an option that can be added
 * to a {@link SiteSprocketProject}
 *
 * @package SiteSprocket
 * @author <NAME>
 */

class SiteSprocketProductOption extends DataObject
{
	static $db = array (
		'Title' => 'Varchar',
		'Description' => 'HTMLText',
		'Price' => 'Currency',
		'AllowUploads' => 'Boolean',
		'UploadText' => 'Text'
	);
	
	static $has_one = array (
		'Group' => 'SiteSprocketProductGroup',
		'SiteSprocket' => 'SiteSprocket'
	);
	
	static $has_many = array (
		'Uploads' => 'SiteSprocketFile'
	);
	
	static $summary_fields = array (
		'Title' => 'Title',
		'Group.Title' => 'Group',
		'Description' => 'Description',
		'Price' => 'Price',
		'AllowUploadsNice' => 'Allow uploads?',
		'UploadText' => 'Upload text'
	);
	
	static $searchable_fields = array (
		'Title'
	);
	
	public function canCreate() {
		return true;	
	}
	
	public function canDelete() {
		return true;	
	}
	
	public function canEdit() {
		return true;
	}
	
	/**
	 * Returns a readable yes/no for the AllowUploads boolean
	 *
	 * @return string
	 */
	public function getAllowUploadsNice() {
		return $this->obj('AllowUploads')->Nice();
	}
	
	public function getCMSFields() {
		$set = DataObject::get("SiteSprocketProductGroup");
		$map = $set ? $set->toDropdownMap() : array();
		$f = new FieldSet (
			new TextField('Title', _t('SSP.OPTIONTITLE','Title')),
			$d = new DropdownField('GroupID', _t('SSP.OPTIONGROUP','Group'), $map),
			new TextareaField('Description', _t('SSP.OPTIONDESCRIPTION','Description')),
			new CurrencyField('Price', _t('SSP.OPTIONPRICE','Price')),
			new CheckboxField('AllowUploads', _t('SSP.ALLOWUPLOADS','Allow uploads')),
			new TextareaField('UploadText', _t('SSP.UPLOADTEXT','Upload text'))
		);
		$d->setEmptyString(_t('SSP.CHOOSEGROUP','-- Please select a group --'));
		return $f;
	}
	
	
	/**
	 * Template accessor for an upload field for this option
	 *
	 * @return UploadifyField
	 */
	public function UploadField() {
		$f = new UploadifyField("Upload_{$this->ID}");
		return $f;
	}
	
	
	/**
	 * Has the user selected this option?
	 *
	 * @return boolean
	 */
	public function Selected() {
		$data = Session::get("FormInfo.Form_OrderForm.data");
		if(isset($data['Options']) && is_array($data['Options'])) {
			return in_array($this->ID, $data['Options']);
		}
		return false;
			
	}
}<commit_msg>ADD - Updates for ARB functionality<commit_after><?php

/**
 * Defines the SiteSprocketProductOption data type, representing an option that can be added
 * to a {@link SiteSprocketProject}
 *
 * @package SiteSprocket
 * @author <NAME>
 */

class SiteSprocketProductOption extends DataObject
{
	static $db = array (
		'Title' => 'Varchar',
		'Description' => 'HTMLText',
		'Price' => 'Currency',
		'AllowUploads' => 'Boolean',
		'UploadText' => 'Text',
		'IsRecurring' => 'Boolean',
		'RecurringStart' => 'Date',
		'RecurringEnd' => 'Date',
		'RecurringAmount' => 'Int',
		'RecurringLength' => 'Int',
		'RecurringUnit' => "Enum('months,days')"
	);
	
	static $has_one = array (
		'Group' => 'SiteSprocketProductGroup',
		'SiteSprocket' => 'SiteSprocket'
	);
	
	static $has_many = array (
		'Uploads' => 'SiteSprocketFile'
	);
	
	static $summary_fields = array (
		'Title' => 'Title',
		'Group.Title' => 'Group',
		'Description' => 'Description',
		'Price' => 'Price',
		'AllowUploadsNice' => 'Allow uploads?',
		'UploadText' => 'Upload text'
	);
	
	static $searchable_fields = array (
		'Title'
	);
	
	public function canCreate() {
		return true;	
	}
	
	public function canDelete() {
		return true;	
	}
	
	public function canEdit() {
		return true;
	}
	
	/**
	 * Returns a readable yes/no for the AllowUploads boolean
	 *
	 * @return string
	 */
	public function getAllowUploadsNice() {
		return $this->obj('AllowUploads')->Nice();
	}
	
	public function getCMSFields() {
		$set = DataObject::get("SiteSprocketProductGroup");
		$map = $set ? $set->toDropdownMap() : array();
		$f = new FieldSet (
			new TextField('Title', _t('SSP.OPTIONTITLE','Title')),
			$d = new DropdownField('GroupID', _t('SSP.OPTIONGROUP','Group'), $map),
			new TextareaField('Description', _t('SSP.OPTIONDESCRIPTION','Description')),
			new CurrencyField('Price', _t('SSP.OPTIONPRICE','Price')),
			new CheckboxField('AllowUploads', _t('SSP.ALLOWUPLOADS','Allow uploads')),
			new TextareaField('UploadText', _t('SSP.UPLOADTEXT','Upload text')),
			new CheckboxField('IsRecurring', _t('SSP.ISRECURRING','Recurring?')),
			new DatePickerField('RecurringStart', _t('SSP.RECURRINGSTART','Start of recurring billing')),
			new DatePickerField('RecurringEnd', _t('SSP.RECURRINGEND','End of recurring billing')),
			new FieldGroup(
				new LiteralField('bill', _t('SSP.BILLTHECARD','Bill the card $')),
				new NumericField('RecurringAmount',''),
				new LiteralField('every',_t('SSP.EVERY','every')),
				new NumericField('RecurringLength',''),
				new DropdownField('RecurringUnit','', $this->dbObject('RecurringUnit')->enumValues())
			)
		);
		$d->setEmptyString(_t('SSP.CHOOSEGROUP','-- Please select a group --'));
		return $f;
	}
	
	
	/**
	 * Template accessor for an upload field for this option
	 *
	 * @return UploadifyField
	 */
	public function UploadField() {
		$f = new UploadifyField("Upload_{$this->ID}");
		return $f;
	}
	
	
	/**
	 * Has the user selected this option?
	 *
	 * @return boolean
	 */
	public function Selected() {
		$data = Session::get("FormInfo.Form_OrderForm.data");
		if(isset($data['Options']) && is_array($data['Options'])) {
			return in_array($this->ID, $data['Options']);
		}
		return false;
			
	}
}
{'fraction_non_alphanumeric': 0.1750445632798574, 'fraction_numerical': 0.0, 'mean_word_length': 4.395192307692308, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 53, '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': '1683620', 'n_tokens_mistral': 2137, 'n_tokens_neox': 1918, 'n_words': 409}