<commit_before><?php

/**
 * Class to copy chunks from one page version to another.
 * 
 */
class Boom_Page_ChunkCopier
{
	/**
	 * Associative array of slotnames to exclude from copy. e.g.:
	 *
	 *	array(
	 *		'text' = array('bodycopy')
	 *	);
	 *
	 * @var array
	 */
	protected $_exclude;

	/**
	 *
	 * @var Model_Page_Version
	 */
	protected $_from_version;

	/**
	 *
	 * @var Model_Page_Version
	 */
	protected $_to_version;

	public function __construct(Model_Page_Version $from_version, Model_Page_Version $to_version, array $exclude = NULL)
	{
		$this->_from_version = $from_version;
		$this->_to_version = $to_version;
		$this->_exclude = $exclude;
	}

	public function copy_all()
	{
		return $this
			->copy_assets()
			->copy_features()
			->copy_linksets()
			->copy_slideshows()
			->copy_text()
			->copy_timestamps();
	}
	
	public function copy_assets()
	{
		return $this->_do_simple_copy('asset');
	}

	public function copy_features()
	{
		return $this->_do_simple_copy('feature');
	}

	public function copy_linksets()
	{
		$this->_do_simple_copy('linkset');
		$linksets = ORM::factory('Chunk_Linkset')->where('page_vid', '=', $this->_to_version->id)->find_all();

		foreach ($linksets as $linkset)
		{
			$linkset->copy($this->_from_version->id);
		}

		return $this;
	}

	public function copy_slideshows()
	{
		$this->_do_simple_copy('slideshow');

		$slideshows = ORM::factory('Chunk_Slideshow')->where('page_vid', '=', $this->_to_version->id)->find_all();

		foreach ($slideshows as $slideshow)
		{
			$slideshow->copy($this->_from_version->id);
		}

		return $this;
	}

	public function copy_text()
	{
		return $this->_do_simple_copy('text');
	}

	public function copy_timestamps()
	{
		return $this->_do_simple_copy('timestamp');
	}
<commit_msg>Bugfix: tag chunks not copied by Page_ChunkCopier<commit_after><?php

/**
 * Class to copy chunks from one page version to another.
 * 
 */
class Boom_Page_ChunkCopier
{
	/**
	 * Associative array of slotnames to exclude from copy. e.g.:
	 *
	 *	array(
	 *		'text' = array('bodycopy')
	 *	);
	 *
	 * @var array
	 */
	protected $_exclude;

	/**
	 *
	 * @var Model_Page_Version
	 */
	protected $_from_version;

	/**
	 *
	 * @var Model_Page_Version
	 */
	protected $_to_version;

	public function __construct(Model_Page_Version $from_version, Model_Page_Version $to_version, array $exclude = NULL)
	{
		$this->_from_version = $from_version;
		$this->_to_version = $to_version;
		$this->_exclude = $exclude;
	}

	public function copy_all()
	{
		return $this
			->copy_assets()
			->copy_features()
			->copy_linksets()
			->copy_slideshows()
			->copy_text()
			->copy_timestamps()
			->copy_tags();
	}
	
	public function copy_assets()
	{
		return $this->_do_simple_copy('asset');
	}

	public function copy_features()
	{
		return $this->_do_simple_copy('feature');
	}

	public function copy_linksets()
	{
		$this->_do_simple_copy('linkset');
		$linksets = ORM::factory('Chunk_Linkset')->where('page_vid', '=', $this->_to_version->id)->find_all();

		foreach ($linksets as $linkset)
		{
			$linkset->copy($this->_from_version->id);
		}

		return $this;
	}

	public function copy_slideshows()
	{
		$this->_do_simple_copy('slideshow');

		$slideshows = ORM::factory('Chunk_Slideshow')->where('page_vid', '=', $this->_to_version->id)->find_all();

		foreach ($slideshows as $slideshow)
		{
			$slideshow->copy($this->_from_version->id);
		}

		return $this;
	}

	public function copy_tags()
	{
		return $this->_do_simple_copy('tag');
	}

	public function copy_text()
	{
		return $this->_do_simple_copy('text');
	}

	public function copy_timestamps()
	{
		return $this->_do_simple_copy('timestamp');
	}

{'fraction_non_alphanumeric': 0.16261273572014212, 'fraction_numerical': 0.0, 'mean_word_length': 4.069252077562327, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 63, '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': '4102036', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1307, 'n_words': 234}