Add resource revisions to the timeline and add proper templates and
rendering for resources and resource revisions (this is needed later on for the taxonomy). Directly link to individual resource / page revisions from the timeline as well.
This commit is contained in:
parent
0f4c952cbd
commit
5ffe66cbfb
@ -218,7 +218,7 @@ class IDF_Wiki_Page extends Pluf_Model
|
|||||||
'create' => true,
|
'create' => true,
|
||||||
'date' => $date)
|
'date' => $date)
|
||||||
);
|
);
|
||||||
$tmpl = new Pluf_Template('idf/wiki/feedfragment.xml');
|
$tmpl = new Pluf_Template('idf/wiki/feedfragment-page.xml');
|
||||||
return $tmpl->render($context);
|
return $tmpl->render($context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ class IDF_Wiki_PageRevision extends Pluf_Model
|
|||||||
|
|
||||||
function postSave($create=false)
|
function postSave($create=false)
|
||||||
{
|
{
|
||||||
$prj = $this->get_wikipage()->get_project();
|
$page = $this->get_wikipage();
|
||||||
|
|
||||||
if ($create) {
|
if ($create) {
|
||||||
// Check if more than one revision for this page. We do
|
// Check if more than one revision for this page. We do
|
||||||
@ -148,7 +148,7 @@ class IDF_Wiki_PageRevision extends Pluf_Model
|
|||||||
$sql = new Pluf_SQL('wikipage=%s', array($this->wikipage));
|
$sql = new Pluf_SQL('wikipage=%s', array($this->wikipage));
|
||||||
$rev = Pluf::factory('IDF_Wiki_PageRevision')->getList(array('filter'=>$sql->gen()));
|
$rev = Pluf::factory('IDF_Wiki_PageRevision')->getList(array('filter'=>$sql->gen()));
|
||||||
if ($rev->count() > 1) {
|
if ($rev->count() > 1) {
|
||||||
IDF_Timeline::insert($this, $prj, $this->get_submitter());
|
IDF_Timeline::insert($this, $page->get_project(), $this->get_submitter());
|
||||||
foreach ($rev as $r) {
|
foreach ($rev as $r) {
|
||||||
if ($r->id != $this->id and $r->is_head) {
|
if ($r->id != $this->id and $r->is_head) {
|
||||||
$r->is_head = false;
|
$r->is_head = false;
|
||||||
@ -156,11 +156,11 @@ class IDF_Wiki_PageRevision extends Pluf_Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$page = $this->get_wikipage();
|
|
||||||
$page->update(); // Will update the modification timestamp.
|
|
||||||
IDF_Search::index($page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IDF_Search::index($page);
|
||||||
|
$page->update(); // Will update the modification timestamp.
|
||||||
|
|
||||||
// remember the resource revisions used in this page revision
|
// remember the resource revisions used in this page revision
|
||||||
if ($this->is_head) {
|
if ($this->is_head) {
|
||||||
preg_match_all('#\[\[!([A-Za-z0-9\-]+)[^\]]*\]\]#im', $this->content, $matches, PREG_PATTERN_ORDER);
|
preg_match_all('#\[\[!([A-Za-z0-9\-]+)[^\]]*\]\]#im', $this->content, $matches, PREG_PATTERN_ORDER);
|
||||||
@ -183,9 +183,11 @@ class IDF_Wiki_PageRevision extends Pluf_Model
|
|||||||
public function timelineFragment($request)
|
public function timelineFragment($request)
|
||||||
{
|
{
|
||||||
$page = $this->get_wikipage();
|
$page = $this->get_wikipage();
|
||||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::viewPage',
|
$url = Pluf::f('url_base')
|
||||||
|
.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::viewPage',
|
||||||
array($request->project->shortname,
|
array($request->project->shortname,
|
||||||
$page->title));
|
$page->title),
|
||||||
|
array('rev' => $this->id));
|
||||||
$out = "\n".'<tr class="log"><td><a href="'.$url.'">'.
|
$out = "\n".'<tr class="log"><td><a href="'.$url.'">'.
|
||||||
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
|
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
|
||||||
'</a></td><td>';
|
'</a></td><td>';
|
||||||
@ -220,18 +222,12 @@ class IDF_Wiki_PageRevision extends Pluf_Model
|
|||||||
public function feedFragment($request)
|
public function feedFragment($request)
|
||||||
{
|
{
|
||||||
$page = $this->get_wikipage();
|
$page = $this->get_wikipage();
|
||||||
if (!$this->is_head) {
|
|
||||||
$url = Pluf::f('url_base')
|
$url = Pluf::f('url_base')
|
||||||
.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::viewPage',
|
.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::viewPage',
|
||||||
array($request->project->shortname,
|
array($request->project->shortname,
|
||||||
$page->title),
|
$page->title),
|
||||||
array('rev' => $this->id));
|
array('rev' => $this->id));
|
||||||
} else {
|
|
||||||
$url = Pluf::f('url_base')
|
|
||||||
.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::viewPage',
|
|
||||||
array($request->project->shortname,
|
|
||||||
$page->title));
|
|
||||||
}
|
|
||||||
$title = sprintf(__('%1$s: Documentation page %2$s updated - %3$s'),
|
$title = sprintf(__('%1$s: Documentation page %2$s updated - %3$s'),
|
||||||
$request->project->name,
|
$request->project->name,
|
||||||
$page->title, $page->summary);
|
$page->title, $page->summary);
|
||||||
@ -245,7 +241,7 @@ class IDF_Wiki_PageRevision extends Pluf_Model
|
|||||||
'create' => false,
|
'create' => false,
|
||||||
'date' => $date)
|
'date' => $date)
|
||||||
);
|
);
|
||||||
$tmpl = new Pluf_Template('idf/wiki/feedfragment.xml');
|
$tmpl = new Pluf_Template('idf/wiki/feedfragment-page.xml');
|
||||||
return $tmpl->render($context);
|
return $tmpl->render($context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ class IDF_Wiki_Resource extends Pluf_Model
|
|||||||
$user = $stag->start($this->get_submitter(), $request, '', false);
|
$user = $stag->start($this->get_submitter(), $request, '', false);
|
||||||
$out .= sprintf(__('<a href="%1$s" title="View resource">%2$s</a>, %3$s'), $url, Pluf_esc($this->title), Pluf_esc($this->summary)).'</td>';
|
$out .= sprintf(__('<a href="%1$s" title="View resource">%2$s</a>, %3$s'), $url, Pluf_esc($this->title), Pluf_esc($this->summary)).'</td>';
|
||||||
$out .= "\n".'<tr class="extra"><td colspan="2">
|
$out .= "\n".'<tr class="extra"><td colspan="2">
|
||||||
<div class="helptext right">'.sprintf(__('Creation of <a href="%1$s">page %2$s</a>, by %3$s'), $url, Pluf_esc($this->title), $user).'</div></td></tr>';
|
<div class="helptext right">'.sprintf(__('Creation of <a href="%1$s">resource %2$s</a>, by %3$s'), $url, Pluf_esc($this->title), $user).'</div></td></tr>';
|
||||||
return Pluf_Template::markSafe($out);
|
return Pluf_Template::markSafe($out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ class IDF_Wiki_Resource extends Pluf_Model
|
|||||||
.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::viewResource',
|
.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::viewResource',
|
||||||
array($request->project->shortname,
|
array($request->project->shortname,
|
||||||
$this->title));
|
$this->title));
|
||||||
$title = sprintf(__('%1$s: Documentation page %2$s added - %3$s'),
|
$title = sprintf(__('%1$s: Documentation resource %2$s added - %3$s'),
|
||||||
$request->project->name,
|
$request->project->name,
|
||||||
$this->title, $this->summary);
|
$this->title, $this->summary);
|
||||||
$date = Pluf_Date::gmDateToGmString($this->creation_dtime);
|
$date = Pluf_Date::gmDateToGmString($this->creation_dtime);
|
||||||
@ -193,12 +193,12 @@ class IDF_Wiki_Resource extends Pluf_Model
|
|||||||
$request,
|
$request,
|
||||||
array('url' => $url,
|
array('url' => $url,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'page' => $this,
|
'resource' => $this,
|
||||||
'rev' => $this->get_current_revision(),
|
'rev' => $this->get_current_revision(),
|
||||||
'create' => true,
|
'create' => true,
|
||||||
'date' => $date)
|
'date' => $date)
|
||||||
);
|
);
|
||||||
$tmpl = new Pluf_Template('idf/wiki/feedfragment.xml');
|
$tmpl = new Pluf_Template('idf/wiki/feedfragment-resource.xml');
|
||||||
return $tmpl->render($context);
|
return $tmpl->render($context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,7 @@ class IDF_Wiki_ResourceRevision extends Pluf_Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
@unlink($this->getFilePath());
|
@unlink($this->getFilePath());
|
||||||
|
IDF_Timeline::remove($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
function preSave($create=false)
|
function preSave($create=false)
|
||||||
@ -147,10 +148,13 @@ class IDF_Wiki_ResourceRevision extends Pluf_Model
|
|||||||
|
|
||||||
function postSave($create=false)
|
function postSave($create=false)
|
||||||
{
|
{
|
||||||
|
$resource = $this->get_wikiresource();
|
||||||
|
|
||||||
if ($create) {
|
if ($create) {
|
||||||
$sql = new Pluf_SQL('wikiresource=%s', array($this->wikiresource));
|
$sql = new Pluf_SQL('wikiresource=%s', array($this->wikiresource));
|
||||||
$rev = Pluf::factory('IDF_Wiki_ResourceRevision')->getList(array('filter'=>$sql->gen()));
|
$rev = Pluf::factory('IDF_Wiki_ResourceRevision')->getList(array('filter'=>$sql->gen()));
|
||||||
if ($rev->count() > 1) {
|
if ($rev->count() > 1) {
|
||||||
|
IDF_Timeline::insert($this, $resource->get_project(), $this->get_submitter());
|
||||||
foreach ($rev as $r) {
|
foreach ($rev as $r) {
|
||||||
if ($r->id != $this->id and $r->is_head) {
|
if ($r->id != $this->id and $r->is_head) {
|
||||||
$r->is_head = false;
|
$r->is_head = false;
|
||||||
@ -158,10 +162,10 @@ class IDF_Wiki_ResourceRevision extends Pluf_Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update the modification timestamp
|
|
||||||
$resource = $this->get_wikiresource();
|
|
||||||
$resource->update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update the modification timestamp
|
||||||
|
$resource->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFilePath()
|
function getFilePath()
|
||||||
@ -285,4 +289,52 @@ class IDF_Wiki_ResourceRevision extends Pluf_Model
|
|||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function timelineFragment($request)
|
||||||
|
{
|
||||||
|
$resource = $this->get_wikiresource();
|
||||||
|
$url = Pluf::f('url_base')
|
||||||
|
.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::viewResource',
|
||||||
|
array($request->project->shortname,
|
||||||
|
$resource->title),
|
||||||
|
array('rev' => $this->id));
|
||||||
|
|
||||||
|
$out = "\n".'<tr class="log"><td><a href="'.$url.'">'.
|
||||||
|
Pluf_esc(Pluf_Template_dateAgo($this->creation_dtime, 'without')).
|
||||||
|
'</a></td><td>';
|
||||||
|
$stag = new IDF_Template_ShowUser();
|
||||||
|
$user = $stag->start($this->get_submitter(), $request, '', false);
|
||||||
|
$out .= sprintf(__('<a href="%1$s" title="View resource">%2$s</a>, %3$s'), $url, Pluf_esc($resource->title), Pluf_esc($this->summary));
|
||||||
|
$out .= '</td></tr>';
|
||||||
|
$out .= "\n".'<tr class="extra"><td colspan="2">
|
||||||
|
<div class="helptext right">'.sprintf(__('Change of <a href="%1$s">%2$s</a>, by %3$s'), $url, Pluf_esc($resource->title), $user).'</div></td></tr>';
|
||||||
|
return Pluf_Template::markSafe($out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function feedFragment($request)
|
||||||
|
{
|
||||||
|
$resource = $this->get_wikiresource();
|
||||||
|
$url = Pluf::f('url_base')
|
||||||
|
.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::viewResource',
|
||||||
|
array($request->project->shortname,
|
||||||
|
$resource->title),
|
||||||
|
array('rev' => $this->id));
|
||||||
|
|
||||||
|
$title = sprintf(__('%1$s: Documentation resource %2$s updated - %3$s'),
|
||||||
|
$request->project->name,
|
||||||
|
$resource->title, $resource->summary);
|
||||||
|
$date = Pluf_Date::gmDateToGmString($this->creation_dtime);
|
||||||
|
$context = new Pluf_Template_Context_Request(
|
||||||
|
$request,
|
||||||
|
array('url' => $url,
|
||||||
|
'title' => $title,
|
||||||
|
'resource' => $resource,
|
||||||
|
'rev' => $this,
|
||||||
|
'create' => false,
|
||||||
|
'date' => $date)
|
||||||
|
);
|
||||||
|
$tmpl = new Pluf_Template('idf/wiki/feedfragment-resource.xml');
|
||||||
|
return $tmpl->render($context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<entry>
|
<entry>
|
||||||
<title>{$title}</title>
|
<title>{$title}</title>
|
||||||
<link href="{$url}"/>
|
<link href="{$url}"/>
|
||||||
<id>{$url}:{$rev.id}</id>
|
<id>{$url}:{$rev.id}</id>
|
11
src/IDF/templates/idf/wiki/feedfragment-resource.xml
Normal file
11
src/IDF/templates/idf/wiki/feedfragment-resource.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<entry>
|
||||||
|
<title>{$title}</title>
|
||||||
|
<link href="{$url}"/>
|
||||||
|
<id>{$url}:{$rev.id}</id>
|
||||||
|
<updated>{$date}</updated>
|
||||||
|
<author>{$rev.get_submitter()}</author>
|
||||||
|
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
{if !$create}<p><strong>{trans 'Changes:'}</strong> {$rev.summary}</p>
|
||||||
|
{else}{trans 'Initial creation'}{/if}
|
||||||
|
</div></content>
|
||||||
|
</entry>
|
Loading…
Reference in New Issue
Block a user