Example #1
0
	/**
	* Actively merge the set of templates matched by the data object.
	* May be paginated by setting members correctly. Does not error;
	* return value indicates whether more data needs to be processed.
	*
	* @param	vB_Template_Merge_Data	Potential merge candidates
	*
	* @return	bool					True when all templates are processed, false when more remain
	*/
	public function merge_templates(vB_Template_Merge_Data $data)
	{
		$candidates = $data->fetch_merge_candidates();

		$this->merge_start();

		$this->processed_count = 0;

		while ($template = $this->registry->db->fetch_array($candidates))
		{
			$this->processed_count++;

			if (!$data->can_merge_template($template))
			{
				continue;
			}

			$merge = new vB_Text_Merge_Threeway(
				$template['oldmastertext'],
				$template['newmastertext'],
				$template['customtext'],
				$this->show_output
			);
			$merged_text = $merge->get_merged();

			if ($merged_text)
			{
				$this->merge_success($merged_text, $template);
			}
			else
			{
				$this->merge_conflict($template);
			}

			if ($this->break_merge_early())
			{
				return false;
			}
		}

		return true;
	}
Example #2
0
	function edit_get_merged_text($templateid)
	{
		global $vbphrase;

		$templates = fetch_templates_for_merge($templateid);
		$new = $templates["new"];
		$custom = $templates["custom"];
		$origin = $templates["origin"];

		require_once (DIR . '/includes/class_merge.php');
		$merge = new vB_Text_Merge_Threeway($origin['template_un'], $new['template_un'], $custom['template_un']);
		$chunks = $merge->get_chunks();

		$text = "";
		foreach ($chunks as $chunk)
		{
			if ($chunk->is_stable())
			{
				$text .= $chunk->get_text_original();
			}
			else
			{
				$chunk_text = $chunk->get_merged_text();
				if ($chunk_text === false)
				{
						$new_title = construct_phrase($vbphrase['merge_title_new'], $new['version']);
						$chunk_text = format_conflict_text($chunk->get_text_right(), $chunk->get_text_original(),
							 $chunk->get_text_left(), $origin['version'], $new['version']);
				}
				$text .= $chunk_text;
			}
		}
		return $text;
	}
 /**
  * Actively merge the set of templates matched by the data object.
  * May be paginated by setting members correctly. Does not error;
  * return value indicates whether more data needs to be processed.
  *
  * @param	vB_Template_Merge_Data	Potential merge candidates
  * @param	array										Output data, in array form
  *
  * @return	bool					True when all templates are processed, false when more remain
  */
 public function merge_templates(vB_Template_Merge_Data $data, &$output)
 {
     $candidates = $data->fetch_merge_candidates();
     $this->merge_start();
     $this->processed_count = 0;
     while ($template = $this->registry->db->fetch_array($candidates)) {
         $this->processed_count++;
         if (!$data->can_merge_template($template)) {
             continue;
         }
         $merge = new vB_Text_Merge_Threeway($template['oldmastertext'], $template['newmastertext'], $template['customtext'], $this->show_output);
         $merged_text = $merge->get_merged();
         if ($merged_text) {
             if ($result = $this->merge_success($merged_text, $template)) {
                 $output[] = $result;
             }
         } else {
             if ($result = $this->merge_conflict($template)) {
                 $output[] = $result;
             }
         }
         if ($this->break_merge_early()) {
             return false;
         }
     }
     // Do we have any template merges remaining?
     $data->start_offset += $this->processed_count;
     $data->batch_size = 1;
     $candidates = $data->fetch_merge_candidates();
     if ($template = $this->registry->db->fetch_array($candidates)) {
         return false;
     }
     return true;
 }