phpBB

Code Changes

File: phpbb/event/md_exporter.php

  Unmodified   Added   Modified   Removed
Line 23Line 23

/** @var string phpBB Root Path */
protected $root_path;


/** @var string phpBB Root Path */
protected $root_path;

 

/** @var string The minimum version for the events to return */
protected $min_version;

/** @var string The maximum version for the events to return */
protected $max_version;


/** @var string */
protected $filter;


/** @var string */
protected $filter;

Line 36Line 42
	/**
* @param string $phpbb_root_path
* @param mixed $extension String 'vendor/ext' to filter, null for phpBB core

	/**
* @param string $phpbb_root_path
* @param mixed $extension String 'vendor/ext' to filter, null for phpBB core

 
	* @param string $min_version
* @param string $max_version

	*/

	*/

	public function __construct($phpbb_root_path, $extension = null)

	public function __construct($phpbb_root_path, $extension = null, $min_version = null, $max_version = null)

	{
$this->root_path = $phpbb_root_path;
$this->path = $this->root_path;

	{
$this->root_path = $phpbb_root_path;
$this->path = $this->root_path;

Line 49Line 57
		$this->events = array();
$this->events_by_file = array();
$this->filter = $this->current_event = '';

		$this->events = array();
$this->events_by_file = array();
$this->filter = $this->current_event = '';

 
		$this->min_version = $min_version;
$this->max_version = $max_version;

	}

/**

	}

/**

Line 89Line 99
	{
$this->crawl_eventsmd($md_file, 'styles');


	{
$this->crawl_eventsmd($md_file, 'styles');


		$styles = array('prosilver', 'subsilver2');

		$styles = array('prosilver');

		foreach ($styles as $style)
{
$file_list = $this->get_recursive_file_list(

		foreach ($styles as $style)
{
$file_list = $this->get_recursive_file_list(

Line 147Line 157
			}

list($file_details, $details) = explode("\n* Since: ", $details, 2);

			}

list($file_details, $details) = explode("\n* Since: ", $details, 2);

 

$changed_versions = array();
if (strpos($details, "\n* Changed: ") !== false)
{
list($since, $details) = explode("\n* Changed: ", $details, 2);
while (strpos($details, "\n* Changed: ") !== false)
{
list($changed, $details) = explode("\n* Changed: ", $details, 2);
$changed_versions[] = $changed;
}
list($changed, $description) = explode("\n* Purpose: ", $details, 2);
$changed_versions[] = $changed;
}
else
{

			list($since, $description) = explode("\n* Purpose: ", $details, 2);

			list($since, $description) = explode("\n* Purpose: ", $details, 2);

 
				$changed_versions = array();
}


$files = $this->validate_file_list($file_details);
$since = $this->validate_since($since);


$files = $this->validate_file_list($file_details);
$since = $this->validate_since($since);

 
			$changes = array();
foreach ($changed_versions as $changed)
{
list($changed_version, $changed_description) = $this->validate_changed($changed);

if (isset($changes[$changed_version]))
{
throw new \LogicException("Duplicate change information found for event '{$this->current_event}'");
}

$changes[$changed_version] = $changed_description;
}
$description = trim($description, "\n") . "\n";

if (!$this->version_is_filtered($since))
{
$is_filtered = false;
foreach ($changes as $version => $null)
{
if ($this->version_is_filtered($version))
{
$is_filtered = true;
break;
}
}

if (!$is_filtered)
{
continue;
}
}


$this->events[$event_name] = array(
'event' => $this->current_event,
'files' => $files,
'since' => $since,


$this->events[$event_name] = array(
'event' => $this->current_event,
'files' => $files,
'since' => $since,

 
				'changed'		=> $changes,

				'description'	=> $description,
);
}

return sizeof($this->events);

				'description'	=> $description,
);
}

return sizeof($this->events);

 
	}

/**
* The version to check
*
* @param string $version
* @return bool
*/
protected function version_is_filtered($version)
{
return (!$this->min_version || phpbb_version_compare($this->min_version, $version, '<='))
&& (!$this->max_version || phpbb_version_compare($this->max_version, $version, '>='));

	}

/**
* Format the php events as a wiki table

	}

/**
* Format the php events as a wiki table

 
	*
* @param string $action

	* @return string		Number of events found
*/

	* @return string		Number of events found
*/

	public function export_events_for_wiki()

	public function export_events_for_wiki($action = '')

	{
if ($this->filter === 'adm')

	{
if ($this->filter === 'adm')

 
		{
if ($action === 'diff')
{
$wiki_page = '=== ACP Template Events ===' . "\n";
}
else

		{
$wiki_page = '= ACP Template Events =' . "\n";

		{
$wiki_page = '= ACP Template Events =' . "\n";

 
			}

			$wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n";
$wiki_page .= '! Identifier !! Placement !! Added in Release !! Explanation' . "\n";

			$wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n";
$wiki_page .= '! Identifier !! Placement !! Added in Release !! Explanation' . "\n";

 
		}
else
{
if ($action === 'diff')
{
$wiki_page = '=== Template Events ===' . "\n";

		}
else
{
$wiki_page = '= Template Events =' . "\n";

		}
else
{
$wiki_page = '= Template Events =' . "\n";

 
			}

			$wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n";

			$wiki_page .= '{| class="zebra sortable" cellspacing="0" cellpadding="5"' . "\n";

			$wiki_page .= '! Identifier !! Prosilver Placement (If applicable) !! Subsilver Placement (If applicable) !! Added in Release !! Explanation' . "\n";

			$wiki_page .= '! Identifier !! Prosilver Placement (If applicable) !! Added in Release !! Explanation' . "\n";

		}

foreach ($this->events as $event_name => $event)

		}

foreach ($this->events as $event_name => $event)

Line 193Line 280
			}
else
{

			}
else
{

				$wiki_page .= implode(', ', $event['files']['prosilver']) . ' || ' . implode(', ', $event['files']['subsilver2']);

				$wiki_page .= implode(', ', $event['files']['prosilver']);

			}

$wiki_page .= " || {$event['since']} || " . str_replace("\n", ' ', $event['description']) . "\n";

			}

$wiki_page .= " || {$event['since']} || " . str_replace("\n", ' ', $event['description']) . "\n";

Line 227Line 314
	*/
public function validate_since($since)
{

	*/
public function validate_since($since)
{

		if (!preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?$#', $since))

		if (!$this->validate_version($since))

		{
throw new \LogicException("Invalid since information found for event '{$this->current_event}'");
}

return $since;

		{
throw new \LogicException("Invalid since information found for event '{$this->current_event}'");
}

return $since;

 
	}

/**
* Validate "Changed" Information
*
* @param string $changed
* @return string
* @throws \LogicException
*/
public function validate_changed($changed)
{
if (strpos($changed, ' ') !== false)
{
list($version, $description) = explode(' ', $changed, 2);
}
else
{
$version = $changed;
$description = '';
}

if (!$this->validate_version($version))
{
throw new \LogicException("Invalid changed information found for event '{$this->current_event}'");
}

return array($version, $description);
}

/**
* Validate "version" Information
*
* @param string $version
* @return bool True if valid, false otherwise
*/
public function validate_version($version)
{
return preg_match('#^\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?$#', $version);

	}

/**

	}

/**

Line 246Line 371
	{
$files_list = array(
'prosilver' => array(),

	{
$files_list = array(
'prosilver' => array(),

			'subsilver2'	=> array(),

 
			'adm'			=> array(),
);


			'adm'			=> array(),
);


Line 265Line 389
				if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0)
{
$files_list['prosilver'][] = substr($file, strlen('styles/prosilver/template/'));

				if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0)
{
$files_list['prosilver'][] = substr($file, strlen('styles/prosilver/template/'));

				}
else if (($this->filter !== 'adm') && strpos($file, 'styles/subsilver2/template/') === 0)
{
$files_list['subsilver2'][] = substr($file, strlen('styles/subsilver2/template/'));

 
				}
else if (($this->filter === 'adm') && strpos($file, 'adm/style/') === 0)
{

				}
else if (($this->filter === 'adm') && strpos($file, 'adm/style/') === 0)
{