<commit_before><?php
/**
 * @version     $Id$
 * @package     Nooku_Components
 * @subpackage  Files
 * @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
 */

/**
 * File Validator Command Class
 *
 * @author      <NAME> <http://nooku.assembla.com/profile/ercanozkaya>
 * @package     Nooku_Components
 * @subpackage  Files
 */
class ComFilesCommandValidatorFile extends ComFilesCommandValidatorNode
{
	protected function _databaseBeforeSave(KCommandContext $context)
	{
		$row = $context->caller;

		if (is_string($row->file) && !is_uploaded_file($row->file))
		{
			// remote file
			try {
				$file = $this->getService('com://admin/files.database.row.url');
				$file->setData(array('file' => $row->file));
				$file->load();
				$row->contents = $file->contents;

			} catch (ComFilesDatabaseRowUrlException $e) {
				throw new KControllerException($e->getMessage(), $e->getCode());
			}

			if (empty($row->name))
			{
				$uri = $this->getService('koowa:http.url', array('url' => $row->file));
	        	$path = $uri->getUrl(KHttpUrl::PATH | KHttpUrl::FORMAT);
	        	if (strpos($path, '/') !== false) {
	        		$path = basename($path);
	        	}

	        	$row->name = $path;<commit_msg>Use KCommandContext::getSubject() instead of $command->caller<commit_after><?php
/**
 * @version     $Id$
 * @package     Nooku_Components
 * @subpackage  Files
 * @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
 */

/**
 * File Validator Command Class
 *
 * @author      <NAME> <http://nooku.assembla.com/profile/ercanozkaya>
 * @package     Nooku_Components
 * @subpackage  Files
 */
class ComFilesCommandValidatorFile extends ComFilesCommandValidatorNode
{
	protected function _databaseBeforeSave(KCommandContext $context)
	{
		$row = $context->getSubject();

		if (is_string($row->file) && !is_uploaded_file($row->file))
		{
			// remote file
			try {
				$file = $this->getService('com://admin/files.database.row.url');
				$file->setData(array('file' => $row->file));
				$file->load();
				$row->contents = $file->contents;

			} catch (ComFilesDatabaseRowUrlException $e) {
				throw new KControllerException($e->getMessage(), $e->getCode());
			}

			if (empty($row->name))
			{
				$uri = $this->getService('koowa:http.url', array('url' => $row->file));
	        	$path = $uri->getUrl(KHttpUrl::PATH | KHttpUrl::FORMAT);
	        	if (strpos($path, '/') !== false) {
	        		$path = basename($path);
	        	}

	        	$row->name = $path;
{'fraction_non_alphanumeric': 0.1776889534883721, 'fraction_numerical': 0.006540697674418605, 'mean_word_length': 3.209480122324159, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 46, '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': '1694613', 'n_tokens_mistral': 1019, 'n_tokens_neox': 921, 'n_words': 163}