]*> | \[\[[^]]*\]\] )*
\s* (.*?)
}sx', $this->body, $bodyp, 0)) {
return $bodyp[1];
}
}
function img()
{
$this->img = NULL;
$this->story;
return $this->img;
}
function image()
{
if ($override = @$this->meta['og:image']) {
# prefer specific page image if found in metadata
return $override;
}
if ( preg_match('/\bsrc="([^"]*)"/', $this->img, $src) ) {
return $src[1];
}
}
function thumb($size = '300x')
{
if (!$this->image or $this->image[0] !== '/') return;
return preg_replace(
['{^(?:/thumb/[^/]*)?}', '/\.groot(?=\.\w+$)/'], ["thumb/$size", ''],
$this->image
);
}
}
class PageSearch
{
function __construct($path = '.')
{
$this->iterator = new RecursiveCallbackFilterIterator(
new RecursiveDirectoryIterator($path),
function ($current) {
if ($current->getFilename()[0] === '.') {
# skip hidden files and directories
return FALSE;
}
if ($current->isLink()) {
# ignore symlinks, original contents only
return FALSE;
}
if ($current->isDir()) {
# traverse subdirectories unless untracked in any amount
return !file_exists("$current/.gitignore");
}
# match **/*.html
return preg_match('/(?getFilename());
}
);
}
function files()
{
# order alphabetically by link
$dir = iterator_to_array(new RecursiveIteratorIterator($this->iterator));
array_walk($dir, function (&$row, $name) {
# prepare values for sorting (directory index first)
$row = preg_replace('{/index\.html$}', '', $name);
});
asort($dir);
return $dir;
}
}