<commit_before><?php

use SilverStripe\Filesystem\Storage\AssetNameGenerator;

/**
 * AssetAdmin is the 'file store' section of the CMS.
 * It provides an interface for manipulating the File and Folder objects in the system.
 *
 * @package cms
 * @subpackage assets
 */
class AssetAdmin extends LeftAndMain implements PermissionProvider{

	private static $url_segment = 'assets';

	private static $url_rule = '/$Action/$ID';

	private static $menu_title = 'Files';

	private static $tree_class = 'Folder';

	/**
	 * Amount of results showing on a single page.
	 *
	 * @config
	 * @var int
	 */
	private static $page_length = 15;

	/**
	 * @config
	 * @see Upload->allowedMaxFileSize
	 * @var int
	 */
	private static $allowed_max_file_size;

	private static $allowed_actions = array(
		'addfolder',
		'delete',
		'AddForm',
		'SearchForm',
		'getsubtree'
	);

	/**
	 * Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
	 */
	public function currentPageID() {
		if(is_numeric($this->getRequest()->requestVar('ID')))	{
			return $this->getRequest()->requestVar('ID');
		} elseif (is_numeric($this->urlParams['ID'])) {
			return $this->urlParams['ID'];
		} elseif(Session::get("{$this->class}.currentPage")) {
			return Session::get("{$this->class}.currentPage");
		} else {
			return 0;
		}
	}

	/**
	 * Set up the controller
	 */
	public function init() {
		parent::init();


		Requirements::javascript(CMS_DIR . "/javascript/AssetAdmin.js");
		Requirements::javascript(CMS_DIR . '/javascript/CMSMain.GridField.js');
		Requirements::add_i18n_javascript(CMS_DIR . '/javascript/lang', false, true);
		Requirements::css(CMS_DIR . "/css/screen.css");
		CMSBatchActionHandler::register('delete', 'AssetAdmin_DeleteBatchAction', 'Folder');
	}

	/**
	 * Returns the files and subfolders contained in the currently selected folder,
	 * defaulting to the root node. Doubles as search results, if any search parameters
	 * are set through {@link SearchForm()}.
	 *
	 * @return SS_List
	 */
	public function getList() {
		$folder = $this->currentPage();
		$context = $this->getSearchContext();
		// Overwrite name filter to search both Name and Title attributes
		$context->removeFilterByName('Name');
		$params = $this->getRequest()->requestVar('q');
		$list = $context->getResults($params);

		// Don't filter list when a detail view is requested,
		// to avoid edge cases where the filtered list wouldn't contain the requested
		// record due to faulty session state (current folder not always encoded in URL, see #7408).
		if(!$folder->ID
			&& $this->getRequest()->requestVar('ID') === null
			&& ($this->getRequest()->param('ID') == 'field')
		) {
			return $list;
		}<commit_msg>Removed requirements to non-existant file<commit_after><?php

use SilverStripe\Filesystem\Storage\AssetNameGenerator;

/**
 * AssetAdmin is the 'file store' section of the CMS.
 * It provides an interface for manipulating the File and Folder objects in the system.
 *
 * @package cms
 * @subpackage assets
 */
class AssetAdmin extends LeftAndMain implements PermissionProvider{

	private static $url_segment = 'assets';

	private static $url_rule = '/$Action/$ID';

	private static $menu_title = 'Files';

	private static $tree_class = 'Folder';

	/**
	 * Amount of results showing on a single page.
	 *
	 * @config
	 * @var int
	 */
	private static $page_length = 15;

	/**
	 * @config
	 * @see Upload->allowedMaxFileSize
	 * @var int
	 */
	private static $allowed_max_file_size;

	private static $allowed_actions = array(
		'addfolder',
		'delete',
		'AddForm',
		'SearchForm',
		'getsubtree'
	);

	/**
	 * Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
	 */
	public function currentPageID() {
		if(is_numeric($this->getRequest()->requestVar('ID')))	{
			return $this->getRequest()->requestVar('ID');
		} elseif (is_numeric($this->urlParams['ID'])) {
			return $this->urlParams['ID'];
		} elseif(Session::get("{$this->class}.currentPage")) {
			return Session::get("{$this->class}.currentPage");
		} else {
			return 0;
		}
	}

	/**
	 * Set up the controller
	 */
	public function init() {
		parent::init();


		Requirements::javascript(CMS_DIR . "/javascript/AssetAdmin.js");
		Requirements::add_i18n_javascript(CMS_DIR . '/javascript/lang', false, true);
		Requirements::css(CMS_DIR . "/css/screen.css");
		CMSBatchActionHandler::register('delete', 'AssetAdmin_DeleteBatchAction', 'Folder');
	}

	/**
	 * Returns the files and subfolders contained in the currently selected folder,
	 * defaulting to the root node. Doubles as search results, if any search parameters
	 * are set through {@link SearchForm()}.
	 *
	 * @return SS_List
	 */
	public function getList() {
		$folder = $this->currentPage();
		$context = $this->getSearchContext();
		// Overwrite name filter to search both Name and Title attributes
		$context->removeFilterByName('Name');
		$params = $this->getRequest()->requestVar('q');
		$list = $context->getResults($params);

		// Don't filter list when a detail view is requested,
		// to avoid edge cases where the filtered list wouldn't contain the requested
		// record due to faulty session state (current folder not always encoded in URL, see #7408).
		if(!$folder->ID
			&& $this->getRequest()->requestVar('ID') === null
			&& ($this->getRequest()->param('ID') == 'field')
		) {
			return $list;
		}
{'fraction_non_alphanumeric': 0.14756233717901004, 'fraction_numerical': 0.0033494603647190174, 'mean_word_length': 4.1288167938931295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '2339207', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1595, 'n_words': 466}