<commit_before><?php

/**
 * @author <NAME> <<EMAIL>>
 * @license BSD http://silverstripe.org/BSD-license
 */
class DashboardController extends FrontendModelController {
	
	public static $model_class = 'DashboardPage';
	
	static $url_handlers = array(
		'widget/$ID'					=> 'handleDashlet',
		'dashlet/$ID'					=> 'handleDashlet',	// what it should be
		'board/$URLSegment/$MemberID'	=> 'handleBoard',
		'user/$Identifier/$Segment'		=> 'handleUser',
	);

	public static $allowed_actions = array(
		'index',
		'board',
		'handleDashlet',
		'handleBoard',
		'adddashlet',
		'AddDashletForm',
		'updateDashboard',
		'DashboardForm',
		'editorfor',
		'EditDashletForm',
		'loaddashlet',
		'deletedashlet'
	);

	private static $allowed_dashlets = array();
	
	public static $dependencies = array(
		'injector'				=> '%$Injector', 
		'securityContext'		=> '%$SecurityContext',
		'dataService'			=> '%$DataService',
	);

	public $injector;
	public $securityContext;
	
	/**
	 * @var DataService
	 */
	public $dataService;
	
	protected $currentDashboard;

	public function __construct($page=null, $dashboard=null) {
		if ($dashboard && $dashboard instanceof DashboardPage) {
			$this->currentDashboard = $dashboard;
		}

		if (!count(self::$allowed_dashlets)) {
			$widgets = ClassInfo::subclassesFor('Dashlet');
			array_shift($widgets);
			self::$allowed_dashlets = array_combine($widgets, $widgets);
		}

		parent::__construct($page);
	}

	/**
	 * Get the currnet dashboard that the user is viewing
	 */
	public function getCurrentDashboard() {
		return $this->currentDashboard;
	}
	
	public function init() {
		
		if (!$this->currentDashboard) {
			Restrictable::set_enabled(false);
			if (Member::currentUserID()) {
				Restrictable::set_enabled(true);
				$this->currentDashboard = $this->getDashboard();
			}
			Restrictable::set_enabled(true);
		}
		
		parent::init();
		
		if ($this->currentDashboard && !$this->currentDashboard->checkPerm('View')) {
			if (!Member::currentUserID() && !$this->redirectedTo()) {
				Security::permissionFailure($this, "You must be logged in");
				return;
			}
		}
		

		// add the following to your own page init() to ensure requirements
		// are met - but you're likely to have them anyway.
		// Requirements::javascript('dashboards/javascript/jquery-1.4.3.min.js');
		// Requirements::javascript('dashboards/javascript/jquery-ui-1.8.5.custom.min.js');
		
//		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
		
		Requirements::javascript('frontend-dashboards/javascript/jquery.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
		
		Requirements::javascript(THIRDPARTY_DIR.'/jquery-form/jquery.form.js');
		Requirements::javascript(THIRDPARTY_DIR.'/jquery-livequery/jquery.livequery.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
		Requirements::javascript('frontend-dashboards/thirdparty/jquery-cookie/jquery.cookie.js');
		
		Requirements::javascript(FRAMEWORK_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js');
		
		Requirements::javascript('frontend-dashboards/javascript/dashboards.js');
//		Requirements::javascript('frontend-dashboards/thirdparty/colorpicker/jquery.colorpicker.js');
//		Requirements::css('frontend-dashboards/thirdparty/colorpicker/jquery.colorpicker.css');

		Requirements::javascript('frontend-dashboards/javascript/dashboard-dialogs.js');
		Requirements::css('frontend-dashboards/css/dashboards.css');
		
		Requirements::javascript('frontend-dashboards/javascript/jquery.gridster.js');
		Requirements::css('frontend-dashboards/css/jquery.gridster.css');
//		Requirements::javascript('frontend-dashboards/javascript/jquery.gridly.js');
//		Requirements::css('frontend-dashboards/css/jquery.gridly.css');

	}

	public static function set_allowed_dashlets($dashlets) {
		self::$allowed_dashlets = $dashlets;
	}

	protected $allowedDashlets = null;
	
	public static function get_allowed_dashlets() {
		return self::$allowed_dashlets;<commit_msg>Fix inclusions to use correct version of jquery required for the dashlet layout engine<commit_after><?php

/**
 * @author <NAME> <<EMAIL>>
 * @license BSD http://silverstripe.org/BSD-license
 */
class DashboardController extends FrontendModelController {
	
	public static $model_class = 'DashboardPage';
	
	static $url_handlers = array(
		'widget/$ID'					=> 'handleDashlet',
		'dashlet/$ID'					=> 'handleDashlet',	// what it should be
		'board/$URLSegment/$MemberID'	=> 'handleBoard',
		'user/$Identifier/$Segment'		=> 'handleUser',
	);

	public static $allowed_actions = array(
		'index',
		'board',
		'handleDashlet',
		'handleBoard',
		'adddashlet',
		'AddDashletForm',
		'updateDashboard',
		'DashboardForm',
		'editorfor',
		'EditDashletForm',
		'loaddashlet',
		'deletedashlet'
	);

	private static $allowed_dashlets = array();
	
	public static $dependencies = array(
		'injector'				=> '%$Injector', 
		'securityContext'		=> '%$SecurityContext',
		'dataService'			=> '%$DataService',
	);

	public $injector;
	public $securityContext;
	
	/**
	 * @var DataService
	 */
	public $dataService;
	
	protected $currentDashboard;

	public function __construct($page=null, $dashboard=null) {
		if ($dashboard && $dashboard instanceof DashboardPage) {
			$this->currentDashboard = $dashboard;
		}

		if (!count(self::$allowed_dashlets)) {
			$widgets = ClassInfo::subclassesFor('Dashlet');
			array_shift($widgets);
			self::$allowed_dashlets = array_combine($widgets, $widgets);
		}

		parent::__construct($page);
	}

	/**
	 * Get the currnet dashboard that the user is viewing
	 */
	public function getCurrentDashboard() {
		return $this->currentDashboard;
	}
	
	public function init() {
		
		if (!$this->currentDashboard) {
			Restrictable::set_enabled(false);
			if (Member::currentUserID()) {
				Restrictable::set_enabled(true);
				$this->currentDashboard = $this->getDashboard();
			}
			Restrictable::set_enabled(true);
		}
		
		parent::init();
		
		if ($this->currentDashboard && !$this->currentDashboard->checkPerm('View')) {
			if (!Member::currentUserID() && !$this->redirectedTo()) {
				Security::permissionFailure($this, "You must be logged in");
				return;
			}
		}
		
		Requirements::block(THIRDPARTY_DIR . '/jquery/jquery.js');
		
		Requirements::javascript('frontend-dashboards/javascript/jquery.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
		
		Requirements::javascript(THIRDPARTY_DIR.'/jquery-form/jquery.form.js');
		Requirements::javascript(THIRDPARTY_DIR.'/jquery-livequery/jquery.livequery.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
		Requirements::javascript('frontend-dashboards/thirdparty/jquery-cookie/jquery.cookie.js');
		
		Requirements::javascript(FRAMEWORK_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js');
		
		Requirements::javascript('frontend-dashboards/javascript/dashboards.js');

		Requirements::javascript('frontend-dashboards/javascript/dashboard-dialogs.js');
		Requirements::css('frontend-dashboards/css/dashboards.css');
		
		Requirements::javascript('frontend-dashboards/javascript/jquery.gridster.js');
		Requirements::css('frontend-dashboards/css/jquery.gridster.css');
//		Requirements::javascript('frontend-dashboards/javascript/jquery.gridly.js');
//		Requirements::css('frontend-dashboards/css/jquery.gridly.css');

	}

	public static function set_allowed_dashlets($dashlets) {
		self::$allowed_dashlets = $dashlets;
	}

	protected $allowedDashlets = null;
	
	public static function get_allowed_dashlets() {
		return self::$allowed_dashlets;
{'fraction_non_alphanumeric': 0.1558219178082192, 'fraction_numerical': 0.0007903055848261328, 'mean_word_length': 5.002371541501977, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 41, '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': '3818977', 'n_tokens_mistral': 2691, 'n_tokens_neox': 2433, 'n_words': 364}