<commit_before><?php
/**
 * Reports section of the CMS
 * @package cms
 * @subpackage reports
 */
class ReportAdmin extends LeftAndMain {
	
	static $template_path = null; // defaults to (project)/templates/email
	
	public function init() {
		parent::init();

		Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
		Requirements::javascript(THIRDPARTY_DIR . "/tiny_mce_improvements.js");

		Requirements::javascript(THIRDPARTY_DIR . "/hover.js");
		Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js");
		
		Requirements::javascript(CMS_DIR . "/javascript/SecurityAdmin.js");
        
    	Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain_left.js");
		Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain_right.js");
    	Requirements::javascript(CMS_DIR . "/javascript/CMSMain_left.js");
        

		Requirements::javascript(CMS_DIR . "/javascript/ReportAdmin_left.js");
		Requirements::javascript(CMS_DIR . "/javascript/ReportAdmin_right.js");
		
		Requirements::css(CMS_DIR . "/css/ReportAdmin.css");		
		
		// TODO Find a better solution to integrate optional Requirements in a specific order
		if(Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
			Requirements::css("ecommerce/css/DataReportCMSMain.css");		
		}
		if(Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
			Requirements::javascript("ecommerce/javascript/DataReport.js");		
		}
		if(Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
			Requirements::css(project() . "/css/DataReportCMSMain.css");		
		}
		if(Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
			Requirements::javascript(project() . "/javascript/DataReport.js");		
		}

		// We don't want this showing up in every ajax-response, it should always be present in a CMS-environment
		if(!Director::is_ajax()) {
			Requirements::javascriptTemplate("cms/javascript/tinymce.template.js", array(
				"ContentCSS" => project() . "/css/editor.css",
				"BaseURL" => Director::absoluteBaseURL(),
				"Lang" => i18n::get_tinymce_lang()
			));
		}
	}
	
	public function Link($action = null) {
		return "admin/reports/$action";
	}
	
	/**
	 * Return a DataObjectSet of Report subclasses
	 * that are available for use.
	 *
	 * @return DataObjectSet
	 */
	public function Reports() {
		$processedReports = array();
		$subClasses = ClassInfo::subclassesFor('Report');
		
		if($subClasses) {
			foreach($subClasses as $subClass) {
				if($subClass != 'Report') $processedReports[] = new $subClass();
			}
		}
		
		$reports = new DataObjectSet($processedReports);
		
		return $reports;
	}
	
	/**
	 * Show a report based on the URL query string.
	 *
	 * @param HTTPRequest $request The HTTP request object
	 */
	public function show($request) {
		$params = $request->allParams();
		
		return $this->showWithEditForm($params, $this->reportEditFormFor($params['ID']));	
	}

	/**
	 * @TODO What does this do?
	 *
	 * @param unknown_type $params
	 * @param unknown_type $editForm
	 * @return unknown
	 */
	protected function showWithEditForm($params, $editForm) {
		if(isset($params['ID'])) Session::set('currentPage', $params['ID']);
		if(isset($params['OtherID'])) Session::set('currentOtherID', $params['OtherID']);
		
		if(Director::is_ajax()) {
			SSViewer::setOption('rewriteHashlinks', false);
			
			$result = $this->customise(
				array(
					'EditForm' => $editForm
				)
			)->renderWith($this->getTemplatesWithSuffix('_right'));
			
			return $this->getLastFormIn($result);
		}
		
		return array();
	}
  
  /**
   * For the current report that the user is viewing,
   * return a Form instance with the fields for that
   * report.
   *
   * @return Form
   */
  public function EditForm() {<commit_msg>MINOR Fixed wrong position of return array() in ReportAdmin->showWithEditForm()<commit_after><?php
/**
 * Reports section of the CMS
 * @package cms
 * @subpackage reports
 */
class ReportAdmin extends LeftAndMain {
	
	static $template_path = null; // defaults to (project)/templates/email
	
	public function init() {
		parent::init();

		Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
		Requirements::javascript(THIRDPARTY_DIR . "/tiny_mce_improvements.js");

		Requirements::javascript(THIRDPARTY_DIR . "/hover.js");
		Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js");
		
		Requirements::javascript(CMS_DIR . "/javascript/SecurityAdmin.js");
        
    	Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain_left.js");
		Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain_right.js");
    	Requirements::javascript(CMS_DIR . "/javascript/CMSMain_left.js");
        

		Requirements::javascript(CMS_DIR . "/javascript/ReportAdmin_left.js");
		Requirements::javascript(CMS_DIR . "/javascript/ReportAdmin_right.js");
		
		Requirements::css(CMS_DIR . "/css/ReportAdmin.css");		
		
		// TODO Find a better solution to integrate optional Requirements in a specific order
		if(Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
			Requirements::css("ecommerce/css/DataReportCMSMain.css");		
		}
		if(Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
			Requirements::javascript("ecommerce/javascript/DataReport.js");		
		}
		if(Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
			Requirements::css(project() . "/css/DataReportCMSMain.css");		
		}
		if(Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
			Requirements::javascript(project() . "/javascript/DataReport.js");		
		}

		// We don't want this showing up in every ajax-response, it should always be present in a CMS-environment
		if(!Director::is_ajax()) {
			Requirements::javascriptTemplate("cms/javascript/tinymce.template.js", array(
				"ContentCSS" => project() . "/css/editor.css",
				"BaseURL" => Director::absoluteBaseURL(),
				"Lang" => i18n::get_tinymce_lang()
			));
		}
	}
	
	public function Link($action = null) {
		return "admin/reports/$action";
	}
	
	/**
	 * Return a DataObjectSet of Report subclasses
	 * that are available for use.
	 *
	 * @return DataObjectSet
	 */
	public function Reports() {
		$processedReports = array();
		$subClasses = ClassInfo::subclassesFor('Report');
		
		if($subClasses) {
			foreach($subClasses as $subClass) {
				if($subClass != 'Report') $processedReports[] = new $subClass();
			}
		}
		
		$reports = new DataObjectSet($processedReports);
		
		return $reports;
	}
	
	/**
	 * Show a report based on the URL query string.
	 *
	 * @param HTTPRequest $request The HTTP request object
	 */
	public function show($request) {
		$params = $request->allParams();
		
		return $this->showWithEditForm($params, $this->reportEditFormFor($params['ID']));	
	}

	/**
	 * @TODO What does this do?
	 *
	 * @param unknown_type $params
	 * @param unknown_type $editForm
	 * @return unknown
	 */
	protected function showWithEditForm($params, $editForm) {
		if(isset($params['ID'])) Session::set('currentPage', $params['ID']);
		if(isset($params['OtherID'])) Session::set('currentOtherID', $params['OtherID']);
		
		if(Director::is_ajax()) {
			SSViewer::setOption('rewriteHashlinks', false);
			
			$result = $this->customise(
				array(
					'EditForm' => $editForm
				)
			)->renderWith($this->getTemplatesWithSuffix('_right'));
			
			return $this->getLastFormIn($result);
		} else {
			return array();
		}
	}
  
  /**
   * For the current report that the user is viewing,
   * return a Form instance with the fields for that
   * report.
   *
   * @return Form
   */
  public function EditForm() {
{'fraction_non_alphanumeric': 0.15241388482510973, 'fraction_numerical': 0.0005319856363878176, 'mean_word_length': 4.175498967653131, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, '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': '768114', 'n_tokens_mistral': 2653, 'n_tokens_neox': 2278, 'n_words': 453}