<commit_before><?php

/**
 * Used to edit the SiteTree->URLSegment property, and suggest input based on the serverside rules
 * defined through {@link SiteTree->generateURLSegment()} and {@link URLSegmentFilter}.
 * 
 * Note: The actual conversion for saving the value takes place in the model layer.
 *
 * @package cms
 * @subpackage forms
 */

class SiteTreeURLSegmentField extends TextField {
	
	/** 
	 * @var string 
	 */
	protected $helpText, $urlPrefix;
	
	static $allowed_actions = array(
		'suggest'
	);

	function Field($properties = array()) {
		Requirements::javascript(CMS_DIR . '/javascript/SiteTreeURLSegmentField.js');
		return parent::Field($properties);
	}
	
	function suggest($request) {
		if(!$request->getVar('value')) return $this->httpError(405);<commit_msg>BUGFIX Decode URLSegment before showing it through SiteTreeURLSegmentField, to separate presentation from its internal url encoded value<commit_after><?php

/**
 * Used to edit the SiteTree->URLSegment property, and suggest input based on the serverside rules
 * defined through {@link SiteTree->generateURLSegment()} and {@link URLSegmentFilter}.
 * 
 * Note: The actual conversion for saving the value takes place in the model layer.
 *
 * @package cms
 * @subpackage forms
 */

class SiteTreeURLSegmentField extends TextField {
	
	/** 
	 * @var string 
	 */
	protected $helpText, $urlPrefix;
	
	static $allowed_actions = array(
		'suggest'
	);

	function Value() {
		return rawurldecode($this->value);
	}

	function Field($properties = array()) {
		Requirements::javascript(CMS_DIR . '/javascript/SiteTreeURLSegmentField.js');
		return parent::Field($properties);
	}
	
	function suggest($request) {
		if(!$request->getVar('value')) return $this->httpError(405);
{'fraction_non_alphanumeric': 0.1198394495412844, 'fraction_numerical': 0.0034403669724770644, 'mean_word_length': 4.759075907590759, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '807151', 'n_tokens_mistral': 515, 'n_tokens_neox': 497, 'n_words': 149}