This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/app/helpers/WikiHelper.php

37 lines
1.2 KiB
PHP
Raw Normal View History

2013-10-27 01:06:58 +02:00
<?php
class WikiHelper extends Rails\ActionView\Helper
{
// public function linked_from($to)
// {
// links = to.find_pages_that_link_to_this.map do |page|
// linkTo(h(page.pretty_title), :controller => "wiki", :action => "show", :title => page.title)
// end.join(", ")
// links.empty? ? "None" : links
// }
# Generates content for "Changes" column on history page.
# Not filtered, must return HTML-safe string.
# a is current
# b is previous (or what's a compared to)
public function page_change($a, $b)
{
$changes = $a->diff($b);
if (!$changes)
return 'no change';
else {
return implode(', ', array_map(function($change)use($a, $b) {
switch ($change) {
case 'initial':
return 'first version';
case 'body':
return 'content update';
case 'title':
return "page rename (".$this->h($a->title)."".$this->h($b->title).")";
case 'is_locked':
return $a->is_locked ? 'page lock' : 'page unlock';
};
}, $changes));
}
}
}