<commit_before><?php

/**
 * Adds a function to LeftAndMain to sync disqus comments.
 *
 * @package silverstripe-disqus-module
 * @author <NAME> <admin_silverstripe.sk>
 * @notice SilverStripe.sk is not affiliated with the company SilverStripe Ltd.
 * @date April 2011
 */

class DisqusCMSActionDecorator extends LeftAndMainExtension {
	
	private static $allowed_actions = array(
        'syncAllCommentsAction'
    );
     
    function syncCommentsAction() {	
    	    	
    	$id = (int)$_REQUEST['ID']; 
    	
    	//$page = DataObject::get_by_id("Page",$id);
    	$page = Page::get()->byID($id);

		DisqusSync::sync($page->disqusIdentifier());
    		
        FormResponse::status_message(sprintf('Synced successfuly'),'good');
        return FormResponse::respond();
    }  
	
	function syncAllCommentsAction() {	
    	    	
    	//$pages = DataObject::get("Page","provideComments = 1 AND status = 'Published'"); 
    	// @todo status noo longer works, need alternative way to denote a page being published
    	$pages = Page::get()->filter(array(
    		'ProvideComments'=>'1'
    	));
    	
    	
		if ($pages) {
			foreach ($pages as $page) {
				// TODO: this doesnt work too (sameas HourlyTask). What's the reason?
 				DisqusSync::sync($page->disqusIdentifier());
			}
		}
    		
        FormResponse::status_message(sprintf('Synced successfuly'),'good');
        return FormResponse::respond();
    }  
}

// EOF
<commit_msg>BUGFIX: remove use of FormResponse<commit_after><?php

/**
 * Adds a function to LeftAndMain to sync disqus comments.
 *
 * @package silverstripe-disqus-module
 * @author <NAME> <admin_silverstripe.sk>
 * @notice SilverStripe.sk is not affiliated with the company SilverStripe Ltd.
 * @date April 2011
 */

class DisqusCMSActionDecorator extends LeftAndMainExtension {
	
	private static $allowed_actions = array(
        'syncAllCommentsAction'
    );
     
    function syncCommentsAction() {	
    	    	
    	$id = (int)$_REQUEST['ID']; 
    	
    	//$page = DataObject::get_by_id("Page",$id);
    	$page = Page::get()->byID($id);

		DisqusSync::sync($page->disqusIdentifier());
    		
        $this->owner->response->addHeader('X-Status', sprintf('Synced successfuly'));
        return;
    }  
	
	function syncAllCommentsAction() {	
    	    	
    	//$pages = DataObject::get("Page","provideComments = 1 AND status = 'Published'"); 
    	// @todo status noo longer works, need alternative way to denote a page being published
    	$pages = Page::get()->filter(array(
    		'ProvideComments'=>'1'
    	));
    	
    	
		if ($pages) {
			foreach ($pages as $page) {
				// TODO: this doesnt work too (sameas HourlyTask). What's the reason?
 				DisqusSync::sync($page->disqusIdentifier());
			}
		}
    		
        $this->owner->response->addHeader('X-Status', sprintf('Synced successfuly'));
        return;
    }  
}

// EOF

{'fraction_non_alphanumeric': 0.14006287111421586, 'fraction_numerical': 0.0041914076143905, 'mean_word_length': 2.972260748959778, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, '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': '6625092', 'n_tokens_mistral': 992, 'n_tokens_neox': 918, 'n_words': 198}