<commit_before><?php namespace Milkyway\SS\Extensions;

use Milkyway\SS\Assets;
use Milkyway\SS\Assets_Backend;
use Milkyway\SS\Utilities;

/**
 * Milkyway Multimedia
 * Controller.php
 *
 * @package milkyway-multimedia/silverstripe-mwm
 * @author <NAME> <<EMAIL>>
 */
class Controller extends \Extension {
    function onBeforeInit() {
        foreach(Assets::$disable_cache_busted_file_extensions_for as $class) {
            if (is_a($this->owner, $class))
                Assets::$disable_cache_busted_file_extensions_for;
        }
    }

    public function onAfterInit() {
        foreach(Assets::$disable_blocked_files_for as $class) {
            if (is_a($this->owner, $class))
                return;
        }

        Assets::block();

	    if(Utilities::isFrontendEditingEnabled())
		    \Requirements::unblock(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
    }

    public function getBackLink($fallback = '') {
        if($this->owner->Request) {
            if($this->owner->Request->requestVar('BackURL')) {
                $url = $this->owner->Request->requestVar('BackURL');
            } else if($this->owner->Request->isAjax() && $this->owner->Request->getHeader('X-Backurl')) {
                $url = $this->owner->Request->getHeader('X-Backurl');
            } else if($this->owner->Request->getHeader('Referer')) {
                $url = $this->owner->Request->getHeader('Referer');
            }
        }

        if(!$url)
            $url = $fallback ? $fallback : Director::baseURL();

        return $url;
    }
} <commit_msg>Uploading changes at Mon, 22 Sep 2014 20:05:37 GMT<commit_after><?php namespace Milkyway\SS\Extensions;

use Milkyway\SS\Assets;
use Milkyway\SS\Assets_Backend;
use Milkyway\SS\Director;
use Milkyway\SS\Utilities;

/**
 * Milkyway Multimedia
 * Controller.php
 *
 * @package milkyway-multimedia/silverstripe-mwm
 * @author <NAME> <<EMAIL>>
 */
class Controller extends \Extension {
    function onBeforeInit() {
        foreach(Assets::$disable_cache_busted_file_extensions_for as $class) {
            if (is_a($this->owner, $class))
                Assets::$disable_cache_busted_file_extensions_for;
        }
    }

    public function onAfterInit() {
        foreach(Assets::$disable_blocked_files_for as $class) {
            if (is_a($this->owner, $class))
                return;
        }

        Assets::block();

	    if(Utilities::isFrontendEditingEnabled())
		    \Requirements::unblock(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
    }

    public function getBackLink($fallback = '') {
	    $url = '';

        if($this->owner->Request) {
            if($this->owner->Request->requestVar('BackURL')) {
                $url = $this->owner->Request->requestVar('BackURL');
            } else if($this->owner->Request->isAjax() && $this->owner->Request->getHeader('X-Backurl')) {
                $url = $this->owner->Request->getHeader('X-Backurl');
            } else if($this->owner->Request->getHeader('Referer')) {
                $url = $this->owner->Request->getHeader('Referer');
            }
        }

        if(!$url)
            $url = $fallback ? $fallback : \Director::baseURL();

        return $url;
    }

	public function displayNiceView($controller = null, $url = '', $action = '') {
		if(!$controller)
			$controller = $this->owner;

		return Director::create_view($controller, $url, $action);
	}

	public function respondToFormAppropriately($params, $form = null, $redirect = ''){
		if($redirect && !isset($params['redirect']))
			$params['redirect'] = $redirect;

		if($this->owner->Request->isAjax()) {
			if(!isset($params['code']))
				$params['code'] = 200;
			if(!isset($params['code']))
				$params['status'] = 'success';

			return Director::ajax_response($params, $params['code'], $params['status']);
		}
		else {
			if(isset($params['redirect']))
				$this->owner->redirect($params['redirect']);

			if($form && isset($params['message'])) {
				$form->sessionMessage($params['message'], 'good');
			}

			if(!$this->owner->redirectedTo())
				$this->owner->redirectBack();
		}
	}
} 
{'fraction_non_alphanumeric': 0.17434529582929195, 'fraction_numerical': 0.0036372453928225023, 'mean_word_length': 2.921102661596958, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 70, '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': '7366166', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1268, 'n_words': 188}