<commit_before><?php

/**
 * Extension to {@link DataObject} to enable tracking comments.
 *
 * @package comments
 */

class CommentsExtension extends DataExtension {
	
	/**
	 * Adds a relationship between this {@link DataObject} and its
	 * {@link Comment} objects. If the owner class is a sitetree class
	 * it also enables a checkbox allowing comments to be turned off and off
	 * 
	 * @return array
	 */
	function extraStatics($class = null, $extension = null) {
		$fields = array();
		
		$relationships = array(
			'has_many' => array(
				'Comments' => 'Comment'
			)
		);

		// if it is attached to the SiteTree then we need to add ProvideComments
		// cannot check $this->owner as this in intialised via call_user_func
		$args = func_get_args();
		
		if($args && ($owner = array_shift($args))) {
			if(is_subclass_of($owner, 'SiteTree') || $owner == "SiteTree") {
				$fields = array(
					'db' => array(
						'ProvideComments' => 'Boolean'
					)
				);
			}
		}

		return array_merge($fields, $relationships);
	}

	
	/**
	 * If this extension is applied to a {@link SiteTree} record then
	 * append a Provide Comments checkbox to allow authors to trigger
	 * whether or not to display comments
	 *
	 * @todo Allow customization of other {@link Commenting} configuration
	 *
	 * @param FieldSet
	 */
	public function updateCMSFields(FieldList $fields) {
		if($this->attachedToSiteTree()) {
			$fields->addFieldToTab('Root.Behaviour', 
				new CheckboxField('ProvideComments', _t('Comment.ALLOWCOMMENTS', 'Allow Comments'))
			);
		}
	}
	
	/**
	 * Returns a list of all the comments attached to this record.
	 *
	 * @todo pagination
	 *
	 * @return DataObjectSet
	 */<commit_msg>Put comment configuration on the settings tab<commit_after><?php

/**
 * Extension to {@link DataObject} to enable tracking comments.
 *
 * @package comments
 */

class CommentsExtension extends DataExtension {
	
	/**
	 * Adds a relationship between this {@link DataObject} and its
	 * {@link Comment} objects. If the owner class is a sitetree class
	 * it also enables a checkbox allowing comments to be turned off and off
	 * 
	 * @return array
	 */
	function extraStatics($class = null, $extension = null) {
		$fields = array();
		
		$relationships = array(
			'has_many' => array(
				'Comments' => 'Comment'
			)
		);

		// if it is attached to the SiteTree then we need to add ProvideComments
		// cannot check $this->owner as this in intialised via call_user_func
		$args = func_get_args();
		
		if($args && ($owner = array_shift($args))) {
			if(is_subclass_of($owner, 'SiteTree') || $owner == "SiteTree") {
				$fields = array(
					'db' => array(
						'ProvideComments' => 'Boolean'
					)
				);
			}
		}

		return array_merge($fields, $relationships);
	}

	
	/**
	 * If this extension is applied to a {@link SiteTree} record then
	 * append a Provide Comments checkbox to allow authors to trigger
	 * whether or not to display comments
	 *
	 * @todo Allow customization of other {@link Commenting} configuration
	 *
	 * @param FieldSet
	 */
	public function updateSettingsFields(FieldList $fields) {
		if($this->attachedToSiteTree()) {
			$fields->addFieldToTab('Root.Settings', 
				new CheckboxField('ProvideComments', _t('Comment.ALLOWCOMMENTS', 'Allow Comments'))
			);
		}
	}
	
	/**
	 * Returns a list of all the comments attached to this record.
	 *
	 * @todo pagination
	 *
	 * @return DataObjectSet
	 */
{'fraction_non_alphanumeric': 0.11957796014067995, 'fraction_numerical': 0.0, 'mean_word_length': 3.3700384122919336, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '5379355', 'n_tokens_mistral': 1174, 'n_tokens_neox': 989, 'n_words': 340}