All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
  Print view

Showing revisions for field values
Author Message
PostPosted: Wed Jun 09, 2010 7:12 pm 
Offline

Joined: Sun May 23, 2010 8:32 am
Posts: 3
Hi!
I've been trying to implement the revision archive for field values (from the "how to") and i'm stuck at the part where i'm supposed to show the different revisions(the part missing in the tutorial).can anyone share the edit & view handler and template that the tutorial mentions ?
I would greatly appreciate!Thank you.
Max
PS.This is a great framework!Easy to use and relatively flexible.Congratulations!


Top
 Profile  
 

Re: Showing revisions for field values
PostPosted: Sun Jun 13, 2010 6:10 pm 
Pro
Offline

Joined: Mon May 23, 2005 7:11 am
Posts: 412
Location: Tysse, Samnanger, Norway
I'll try to give some code to get this working:
I didn't put this code in the Wiki beacuse of somedirty coding, and I have not tried
above Atk 5.5.

1)Modify the templates:
In editform.tlp & viewform.tlp add the the following code behind the {$field.full}:
Code:
{$field.full}{if $field.rev_link!=""}{$field.rev_link}{/if}


2) Add the following in the edithandler
just below the tooltip code and before the "$indexno++;":
Code:
if (in_array($field['name'],$node->m_revision_fields)) {
$popupurl="'/include.php?file=show_revision.inc&node=".$node->m_module.'.'.$node->m_type.'&rev_table='.$node->m_table.'&rev_field='.$field['name'].'&rev_atkprimkey='.rawurlencode(str_replace("'",'',$record['atkprimkey']))."'";
$popuptitle="'Revisioner'";
$tplfield["rev_link"]=' <a href="show_revisions.html" onclick="javascript:NewWindow2('.$popupurl.',event,'.$popuptitle.',700,250,1,1);return false;"><u>(Rev)</u></a>';
}


2) Add the following in the view handler
below the tooltip as well, and before the "$tplfield["full"] = $editsrc;":
Code:
if (in_array($field_name,$node->m_revision_fields) and !$simple)
{
$popupurl="'/include.php?file=show_revision.inc&node=".$node->m_module.'.'.$node->m_type.'&rev_table='.$node->m_table.'&rev_field='.$field_name.'&rev_atkprimkey='.rawurlencode(str_replace("'",'',$record['atkprimkey']))."'";
$popuptitle="'Revisioner'";
$tplfield["rev_link"]=' <a href="show_revisions.html" onclick="javascript:NewWindow2('.$popupurl.',event,'.$popuptitle.',700,250,1,1);return false;"><u>(Rev)</u></a>';
}


3 Then file show_revision.inc must be created which must be in allowed_includes & placed in root directory ( in this example):

Code:
<?php
include_once("atk.inc");
atksession();
atksecure();
$lng = atkconfig("language");
$rev_atkprimkey = rawurldecode($_GET["rev_atkprimkey"]);
//echo $rev_atkprimkey;
$rev_table = $_GET["rev_table"];
$rev_field= $_GET["rev_field"];
$module_node = $_GET["node"];
$arr=explode(".",$module_node);
$node=$arr[1];
$module=$arr[0];
$rev_field_text1= atktext("rev_field","revision",$lng);
$rev_field_text2= atktext($rev_field,$module,$lng);
$valuetext=atktext("rev_value","revision",$lng);
if (!$node)
$node=$module;
$SecurityManager=&atkGetSecurityManager();
$nodeobj=&atkGetNode($module_node);
if (!is_object($nodeobj) or $nodeobj->allowed('view')===false)
{
echo "<html><title>Error</title>";
echo '<body onblur="window.close();">';
echo atktext("error_node_action_access_denied","application",$lng );
echo '</body></html>';
die();
}
$title="Revisjonshistorikk for ".atktext("modul","application",$lng );
$title.=": ".atktext($node,$module, $lng );
echo "<html><title>$title</title>";
echo '<body onblur="window.close();">';
$db=&atkGetDb();
$arr=$db->getrows("select replace(rev_value,char(13),'<br>') as rev_value,rev_datetime,rev_username from revision where rev_atkprimkey='$rev_atkprimkey' and rev_table='$rev_table' and rev_field='$rev_field' order by rev_datetime desc");
echo '<div align="left"><a href="javascript:window.close();">'.text("close").'</a></div>';
$data=html_table($arr,true,"revision");
$data=str_replace($valuetext,$rev_field_text1.': '.$rev_field_text2,substr($data,0,50)).substr($data,50);
echo $data;
echo "</body></html>";
die();
function html_table($arr,$header=FALSE,$module="application",$columns=array())
{
  $res="<table border='1'>";
  foreach ($arr as $line)
  {
     if ($header)
       {
       $res.="<tr>";
       foreach ($line as $key=>$col_value)
          if(count($columns)==0 or in_array($key,$columns))
       $res.="<th>".atktext($key,$module)."</th>";
       $res.="</tr>";
       $header=false;
    }
    $res.="<tr>";
    foreach ($line as $key=>$col_value)
      if(count($columns)==0 or in_array($key,$columns))
    $res.="<td>$col_value</td>";
    $res.="</tr>";
  }
  $res.="</table>";
  return $res;
}
?>


There are probably something missing somewhere, but try this first.

_________________
Br
Olav B. Lygre


Top
 Profile  
 

Re: Showing revisions for field values
PostPosted: Mon Jun 14, 2010 12:05 pm 
Offline

Joined: Sun May 23, 2010 8:32 am
Posts: 3
thanks for the reply!
i did what you said and almost got it working in the view mode(the edithandler in atk6.5 is different and i still have to figure out where to insert your code) except that when i press the (rev) link i get show_revisions.html page not found.
I went into include.php and added $config_allowed_includes=array("show_revisions.inc") but still same error. show_revisions.inc is in the root next to atk.inc
do you have any suggestions ?


Top
 Profile  
 

Re: Showing revisions for field values
PostPosted: Mon Jun 14, 2010 9:55 pm 
Pro
Offline

Joined: Mon May 23, 2005 7:11 am
Posts: 412
Location: Tysse, Samnanger, Norway
I knew it was something I missed:
The show_revision.html is not needed, name is just there for the browser to show a link, the onclick event opens the show_revision.inc file.

So try this:

In file newwindow.js in folder javascript add the function NewWindow2 below the NewWindow function:
Code:
function NewWindow2(mypage,evt, myname,w, h, scroll, resize, statusbar, menubar, toolbar, personalbar, titlebar,modal) {
  //alert(evt.screenY);
  var winl =  evt.screenX;
  var wint =  evt.screenY;
  scroll = scroll || 'no';
  statusbar = statusbar || 'no';
  menubar=menubar || 'no';
  toolbar= toolbar || 'no';
  personalbar= personalbar || 'no';
  titlebar= titlebar || 'no';
  resizable= resize || 'no';
  winprops = "height="+h+",width="+w+",top="+wint+",left="+winl+",scrollbars="+scroll+", resizable="+resizable+",status="+statusbar+",menubar="+menubar+",toolbar="+toolbar+",personalbar="+personalbar+",titlebar="+titlebar;
   win = window.open(mypage, myname, winprops) ;
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
  return false;
}

_________________
Br
Olav B. Lygre


Top
 Profile  
 

Re: Showing revisions for field values
PostPosted: Tue Jun 15, 2010 5:34 pm 
Offline

Joined: Sun May 23, 2010 8:32 am
Posts: 3
Thank you! after some small adaptations it worked like a charm!


Top
 Profile  
 

Re: Showing revisions for field values
PostPosted: Wed Apr 19, 2017 1:46 am 
Regular
User avatar
Offline

Joined: Thu Aug 25, 2011 9:31 pm
Posts: 311
Location: Mumbai, India
Good Info but what is the relevance here in revision filed functionality?


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group