phpBB

Code Changes

File: phpbb/event/md_exporter.php

  Unmodified   Added   Modified   Removed
Line 87Line 87
			$this->validate_events_from_file($file_name, $this->crawl_file_for_events($file_name));
}


			$this->validate_events_from_file($file_name, $this->crawl_file_for_events($file_name));
}


		return sizeof($this->events);

		return count($this->events);

	}

/**

	}

/**

Line 113Line 113
			}
}


			}
}


		return sizeof($this->events);

		return count($this->events);

	}

/**

	}

/**

Line 143Line 143

list($event_name, $details) = explode("\n===\n", $event, 2);
$this->validate_event_name($event_name);


list($event_name, $details) = explode("\n===\n", $event, 2);
$this->validate_event_name($event_name);

 
			$sorted_events = [$this->current_event, $event_name];
natsort($sorted_events);

			$this->current_event = $event_name;

if (isset($this->events[$this->current_event]))
{
throw new \LogicException("The event '{$this->current_event}' is defined multiple times");

			$this->current_event = $event_name;

if (isset($this->events[$this->current_event]))
{
throw new \LogicException("The event '{$this->current_event}' is defined multiple times");

 
			}

// Use array_values() to get actual first element and check against natural order
if (array_values($sorted_events)[0] === $event_name)
{
throw new \LogicException("The event '{$sorted_events[1]}' should be defined before '{$sorted_events[0]}'");

			}

if (($this->filter == 'adm' && strpos($this->current_event, 'acp_') !== 0)

			}

if (($this->filter == 'adm' && strpos($this->current_event, 'acp_') !== 0)

Line 219Line 227
			);
}


			);
}


		return sizeof($this->events);

		return count($this->events);

	}

/**

	}

/**

Line 381Line 389
			$files = explode("\n    + ", $file_details);
foreach ($files as $file)
{

			$files = explode("\n    + ", $file_details);
foreach ($files as $file)
{

 
				if (!preg_match('#^([^ ]+)( \([0-9]+\))?$#', $file))
{
throw new \LogicException("Invalid event instances for file '{$file}' found for event '{$this->current_event}'", 1);
}

list($file) = explode(" ", $file);


				if (!file_exists($this->path . $file) || substr($file, -5) !== '.html')
{

				if (!file_exists($this->path . $file) || substr($file, -5) !== '.html')
{

					throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 1);

					throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2);

				}

if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0)

				}

if (($this->filter !== 'adm') && strpos($file, 'styles/prosilver/template/') === 0)

Line 396Line 411
				}
else
{

				}
else
{

					throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 2);

					throw new \LogicException("Invalid file '{$file}' not found for event '{$this->current_event}'", 3);

				}

$this->events_by_file[$file][] = $this->current_event;

				}

$this->events_by_file[$file][] = $this->current_event;

Line 416Line 431
		}
else
{

		}
else
{

			throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 2);

			throw new \LogicException("Invalid file list found for event '{$this->current_event}'", 1);

		}

return $files_list;

		}

return $files_list;

Line 439Line 454
		$event_list = array();
$file_content = file_get_contents($this->path . $file);


		$event_list = array();
$file_content = file_get_contents($this->path . $file);


		$events = explode('<!-- EVENT ', $file_content);
// Remove the code before the first event
array_shift($events);
foreach ($events as $event)
{
$event = explode(' -->', $event, 2);
$event_list[] = array_shift($event);
}

		preg_match_all('/(?:{%|<!--) EVENT (.*) (?:%}|-->)/U', $file_content, $event_list);












		return $event_list;

		return $event_list[1];

	}

/**

	}

/**