openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 6d2fc1c5b243e0ba5d4b2bc2232552e7d5b2f75d
parent 9456d2a697a892daab2f9bd6d4e4ccb758e6780f
Author: Jan Dankert <devnull@localhost>
Date:   Mon, 12 Nov 2012 19:35:00 +0100

Wiederherstellen von Seiteninhalten aus dem Archiv.

Diffstat:
action/PageelementAction.class.php | 56+++++++++++++++++++++++++++++++-------------------------
themes/default/templates/pageelement/archive.tpl.src.xml | 66+++++++++++++++++++++++++++++++++++++++++++++---------------------
2 files changed, 76 insertions(+), 46 deletions(-)

diff --git a/action/PageelementAction.class.php b/action/PageelementAction.class.php @@ -59,15 +59,15 @@ class PageelementAction extends Action { $this->value = new Value(); - $this->page = Session::getObject(); - $id = $this->getRequestVar('id'); $ids = explode('_',$id); if ( count($ids) > 1 ) - list($pageid,$elementid)= $ids; + { + list( $pageid, $elementid ) = $ids; + } else { - $pageid = $this->getRequestId(); + $pageid = $this->getRequestId(); $elementid = $this->getRequestVar('elementid'); } @@ -75,21 +75,12 @@ class PageelementAction extends Action { $this->page = new Page( $pageid ); $this->page->load(); - Session::setObject( $this->page ); - } - else - { - $this->page = Session::getObject(); } if ( $elementid != 0 ) { - $this->element = new Element( $elementid ); - Session::setElement( $this->element ); - } - else - { - $this->element = Session::getElement(); + $this->elementid = $elementid; + $this->element = new Element( $elementid ); } } @@ -100,8 +91,8 @@ class PageelementAction extends Action */ public function propView() { - Http::notFound("",""); - exit(); + Http::noContent(); + $language = Session::getProjectLanguage(); $this->value->languageid = $language->languageid; $this->value->objectid = $this->page->objectid; @@ -717,6 +708,7 @@ class PageelementAction extends Action $otherValue->languageid = $lid; $otherValue->pageid = $this->value->pageid; $otherValue->element = $this->value->element; + $otherValue->elementid = $this->value->elementid; $otherValue->publish = $this->value->publish; $otherValue->load(); $this->setTemplateVar('languagetext' ,wordwrap($otherValue->text,100) ); @@ -751,11 +743,23 @@ class PageelementAction extends Action /** - * Benutzen eines alten Inhaltes + * Wiederherstellung eines alten Inhaltes. */ - function usevalue() + public function usePost() { $this->value->valueid = $this->getRequestVar('valueid'); + $this->value->loadWithId(); + $this->value->element = new Element( $this->value->elementid ); + + if ( $this->value->pageid != $this->page->pageid ) + Http::serverError( 'Cannot find value','page-id does not match' ); + + // Pruefen, ob Berechtigung zum Freigeben besteht + //$this->value->release = $this->page->hasRight(ACL_RELEASE); + $this->value->release = false; + + // Inhalt wieder herstellen, in dem er neu gespeichert wird. + $this->value->save(); } @@ -763,17 +767,17 @@ class PageelementAction extends Action /** * Freigeben eines Inhaltes */ - function release() + public function releasePost() { $this->value->valueid = intval($this->getRequestVar('valueid')); $this->value->loadWithId(); if ( $this->value->pageid != $this->page->pageid ) - die( 'cannot release, bad page' ); + die( 'cannot release, bad page' ); // Pruefen, ob Berechtigung zum Freigeben besteht if ( !$this->page->hasRight(ACL_RELEASE) ) - die( 'cannot release, no right' ); + Http::notAuthorized( 'Cannot release','no right' ); // Inhalt freigeben $this->value->release(); @@ -783,7 +787,7 @@ class PageelementAction extends Action /** * Erzeugt eine Liste aller Versionsst?nde zu diesem Inhalt */ - function archiveView() + public function archiveView() { $this->page->public = true; $this->page->simple = true; @@ -817,10 +821,12 @@ class PageelementAction extends Action // $version_list[ $value->valueid ] = '('.$lfd_nr.') '.$date; $zeile = array( 'value' => Text::maxLaenge( 50,$value->value), + 'objectid' => $this->page->objectid, 'date' => $value->lastchangeTimeStamp, - 'lfd_nr' => $lfd_nr, + 'lfd_nr' => $lfd_nr, 'id' => $value->valueid, - 'user' => $value->lastchangeUserName ); + 'valueid' => $value->valueid, + 'user' => $value->lastchangeUserName ); // Nicht aktive Inhalte k�nnen direkt bearbeitet werden und sind // nach dem Speichern dann wieder aktiv (nat�rlich als n�chster/neuer Inhalt) diff --git a/themes/default/templates/pageelement/archive.tpl.src.xml b/themes/default/templates/pageelement/archive.tpl.src.xml @@ -1,6 +1,7 @@ <output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openrat.de/template ../template.xsd"> - <form method="get" subaction="diff" label="message:compare" cancel="false" visible="true"> + <form method="get" subaction="diff" label="message:compare" + cancel="false" visible="true"> <table widths="5%,5%,5%,15%,15%,35%,10%,10%"> <row class="headline"> <column class="help"> @@ -10,7 +11,9 @@ <if present="compareid"> <text text="GLOBAL_COMPARE"></text> </if> - <else><text raw="_" /></else> + <else> + <text raw="_" /> + </else> </column> <column class="help"> <text text="DATE"></text> @@ -44,13 +47,17 @@ <if present="compareid"> <radio name="compareid" value="var:id"></radio> </if> - <else><text raw="_" /></else> + <else> + <text raw="_" /> + </else> </column> <column> <if present="compareid"> <radio name="withid" value="var:id"></radio> </if> - <else><text raw="_" /></else> + <else> + <text raw="_" /> + </else> </column> <column> <date date="var:date"></date> @@ -61,28 +68,45 @@ <column> <text var="value"></text> </column> - <column class="clickable"> - <if true="var:public"> + <if true="var:public"> + <column> <text key="GLOBAL_PUBLIC" type="strong"></text> + </column> + </if> + <else> + <if present="releaseUrl"> + <column class="clickable"> + <link type="post" subaction="release" var1="valueid" + value1="var:valueid" id="var:objectid" title="message:GLOBAL_RELEASE_DESC"> + <text key="GLOBAL_RELEASE" type="strong"></text> + </link> + </column> </if> <else> - <if present="releaseUrl"> - <link type="open" url="var:releaseUrl" title="message:GLOBAL_RELEASE_DESC"> - <text key="GLOBAL_RELEASE" type="strong"></text> - </link> - </if> - <else> - <text key="GLOBAL_INACTIVE" type="emphatic" /> - </else> - </else> - </column> - <column class="clickable"> - <if true="var:active"> + <column> + <text key="GLOBAL_INACTIVE" type="emphatic" /> + </column> + </else> + </else> + <if true="var:active"> + <column> <text key="GLOBAL_ACTIVE" type="emphatic"></text> + </column> + </if> + <else> + <if present="useUrl"> + <column class="clickable"> + <link type="post" subaction="use" var1="valueid" value1="var:valueid" + id="var:objectid" title="message:GLOBAL_USE_DESC"> + <text key="GLOBAL_USE"></text> + </link> + </column> </if> - <else><if present="useUrl"> - <link type="open" url="var:useUrl" title="message:GLOBAL_USE_DESC"><text key="GLOBAL_USE"></text></link></if></else> - </column> + <else> + <column> + </column> + </else> + </else> </row> </list> </table>