<commit_before> <?php
/**
 * @package     Nooku_Server
 * @subpackage  Weblinks
 * @copyright	Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		http://www.nooku.org
 */

 use Nooku\Library;

/**
 * Weblink Controller Class
 *
 * @author    	<NAME> <http://nooku.assembla.com/profile/gnomeontherun>
 * @package     Nooku_Server
 * @subpackage  Weblinks
 */
class WeblinksControllerWeblink extends ApplicationControllerDefault
{
    public function getRequest()
	{
		$request = parent::getRequest();

		//Display only published items
		$request->query->published = 1;
		
		return $request;
	}
	
	public function _actionRead(Library\CommandContext $context)
	{
        $weblink = parent::_actionRead($context);

		// Redirect the user if the request doesn't include layout=form
		if ($context->request->getFormat() == 'html')
		{           
			if ($weblink->url) {
                $context->response->setRedirect($weblink->url);
			}

			return true;
		}

		return $weblink;
	}
}<commit_msg>Preform a hard redirect through the application dispatcher.<commit_after> <?php
/**
 * @package     Nooku_Server
 * @subpackage  Weblinks
 * @copyright	Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		http://www.nooku.org
 */

 use Nooku\Library;

/**
 * Weblink Controller Class
 *
 * @author    	<NAME> <http://nooku.assembla.com/profile/gnomeontherun>
 * @package     Nooku_Server
 * @subpackage  Weblinks
 */
class WeblinksControllerWeblink extends ApplicationControllerDefault
{
    public function getRequest()
	{
		$request = parent::getRequest();

		//Display only published items
		$request->query->published = 1;
		
		return $request;
	}
	
	public function _actionRead(Library\CommandContext $context)
	{
        $weblink = parent::_actionRead($context);

		// Redirect the user if the request doesn't include layout=form
		if ($context->request->getFormat() == 'html')
		{           
			if ($weblink->url) {
                $this->getObject('application')->redirect($weblink->url);
			}

			return true;
		}

		return $weblink;
	}
}
{'fraction_non_alphanumeric': 0.13640429338103757, 'fraction_numerical': 0.008944543828264758, 'mean_word_length': 3.2772466539196943, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '5524544', 'n_tokens_mistral': 796, 'n_tokens_neox': 720, 'n_words': 159}