function show(&$rows, $current) { //check that the version is at least 1.5.4 //checkVersion(); //ensure mootools is installed JHTML::_('behavior.mootools'); //if we have prior versions, show them if (count($rows) > 0) { //get the editor name $eName = JRequest::getVar('ename'); $eName = preg_replace('#[^A-Z0-9\\-\\_\\[\\]]#i', '', $eName); ?> <style type='text/css'> h1,h2,h3,h4,h5{ margin:2px; } #preview_container { /*height:180px; */ overflow:auto; width:50%; float:left; } #difference_container{ width:49%; float:left; border-left:1px solid black; } #version_pane{ overflow:auto; border-bottom:1px solid black; } .ins,.ins p,.ins a { text-decoration:underline !important; } .del,.del p,.del a { text-decoration:line-through !important; } </style> <script language='javascript' type='text/javascript'> //preview the content function showContent(t){ try { document.getElementById('preview_pane').style.visibility='visible'; document.getElementById('preview').innerHTML = t.title; document.getElementById('difference').innerHTML = t.rev; }catch(e){ alert("Error previewing content: " + e); } } //clear out the preview pane function hideContent(){ document.getElementById('preview_pane').style.visibility='hidden'; document.getElementById('preview').innerHTML = ''; } //asynch request to delete the passed id function requestDelete(id,autosave){ if(confirm('<?php echo JText::_('SURE'); ?> ')){ try { //url to delete if(autosave == 1){ var url = '<?php echo HTML_versions::getLink(); ?> &task=deleteautosave&no_html=1&id=' + id; }else{ var url = '<?php echo HTML_versions::getLink(); ?> &task=delete&no_html=1&id=' + id; } //tell the user when it's gone! var myAjax = new Ajax(url, { method: 'get', update:'version_error', 'onFailure': function(){ alert('<?php echo JText::_('Error deleting version: You are not authorized to delete this version. You did not create it or you are not the administrator.'); ?> '); } , 'onComplete': function(){ //hide the preview hideContent(); //remove the li from the list var d = document.getElementById('versions'); if(id > 0){ var remove = document.getElementById('version_' +id); d.removeChild(remove); }else{ alert('<?php echo JText::_('Error: Version table id numbers are not present. Alter the #__version table id field to be AUTOINCREMENT and this error will go away.'); ?> '); } } }); myAjax.request(); }catch(e){ alert("Error: Is Mootools available?:" + e); } } } //set the editor window to the selected content value function use(t){ try { window.parent.insertVersioning('<?php echo $eName; ?> ',t.title); parent.document.getElementById('title').value = t.rel; window.parent.document.getElementById('sbox-window').close(); }catch(e){ alert("Error inserting content: no editor found"); } } </script> <div id='version_pane'> <div id='version_error'></div> <h3><?php echo JText::_('VERSIONS'); ?> </h3> <!-- <a href="#" onclick="return false;" ><?php echo JText::_('Annotate current version'); ?> </a> --> <ul id='versions'> <?php //get the current version $current_text = str_replace("'", "'", @$current->introtext); if (strlen(@$current->fulltext) > 0) { $current_text = $current_text . '<hr id="system-readmore" />' . str_replace("'", "'", @$current->introtext); } foreach ($rows as $row) { $staged = ""; $autosaved = ""; if (@$row->stage == 1) { $staged = "<i>Staged</i>"; } if (@$row->autosaved == 1) { $autosaved = "<i>Autosaved</i>"; } $hovertext = str_replace("'", "'", @$row->introtext); $title = str_replace("'", "'", @$row->title); //append the fulltext to the content if (strlen($row->fulltext) > 0) { $complete = $hovertext . '<hr id="system-readmore" />' . str_replace("'", "'", @$row->fulltext); } else { $complete = $hovertext; } if (strlen(@$row->modified) > 0) { $ts = @$row->modified; } else { $ts = @$row->created; } //the first version has no modified by info, so we need to use created by instead for the first version only $modified_by_user =& JFactory::getUser((int) @$row->modified_by); $created_by_user =& JFactory::getUser((int) @$row->created_by); if (strlen(trim($modified_by_user->name)) == 0) { $name = $created_by_user->name; } else { $name = $modified_by_user->name; } $diff = htmlDiff($current_text, $complete); $length = (int) strlen($complete); if ($length > 1024) { $length = number_format($length / 1024, 2) . "K"; } if (HTML_versions::canDeleteVersions() === true) { if ($_REQUEST['task'] == 'showautosave') { $delete = "<a href='#' title='" . JText::_('DELETE') . "' onclick='requestDelete({$row->content_id},1); return false;'>[" . JText::_('DELETE') . "]</a>"; } else { $delete = "<a href='#' title='" . JText::_('DELETE') . "' onclick='requestDelete({$row->id},0); return false;'>[" . JText::_('DELETE') . "]</a>"; } } else { $delete = ""; } if (strpos($ts, '0000-00-00') !== false) { $ts = JText::_('Original'); //'(Original)'; } echo "<li id='version_{$row->id}'>{$autosaved} {$staged} {$ts} {$name} ({$length})\n\t\t\t\t\t\t\t<a href='#' title='{$complete}' rel='{$title}' rev='{$diff}' onclick='showContent(this); return false;'>\n\t\t\t\t\t\t\t\t<abbr title='{$hovertext}'>[" . JText::_('PREVIEW') . "]</abbr>\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t<a title='{$complete}' href='#' rel='{$title}' onclick='use(this); return false;' >[" . JText::_('USE') . "]</a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t{$delete}\n\t\t\t\t\t\n\t\t\t\t\t\t </li>"; } ?> </ul> </div> <div id="preview_pane" style="visibility:hidden;"> <div id='preview_container'> <h3><?php echo JText::_('PREVIEW'); ?> </h3> <!-- <h4 id='preview_title'></h4> --> <div id='preview'></div> </div> <div id='difference_container'> <h3 style="display:inline;"><?php echo JText::_('DIFFERENCE'); ?> </h3> (<span class="ins"><?php echo JText::_('ADDED'); ?> </span> <?php echo JText::_('AND'); ?> <span class="del"><?php echo JText::_('DELETED'); ?> </span>) <div id='difference'></div> </div> </div> <script language='javascript'> //add tooltips for previews, not really necessary, but handy //added try/catch try{ window.addEvent('domready', function(){ var abbrTools = new Tips($$('abbr')); }); }catch(e){ } </script> <?php } else { //no prior versions to show ?> <h2><?php echo JText::_('NOVERSIONS'); ?> </h2> <?php } }
$query = "SELECT * FROM #__version WHERE content_id=" . $id . " AND (autosaved != '1' or autosaved is null) ORDER BY id DESC"; } else { //no access to staging versions $query = "SELECT * FROM #__version WHERE content_id=" . $id . " AND (stage != '1' or stage is null) AND (autosaved != '1' or autosaved is null) ORDER BY id DESC"; } } else { $query = "SELECT * FROM #__version WHERE content_id=" . $id . " AND (autosaved != '1' or autosaved is null) ORDER BY id DESC"; } $db->setQuery($query); $rows = $db->loadObjectList(); //get the current article $query = "SELECT * FROM #__content WHERE id=" . $id . " LIMIT 1"; $db->setQuery($query); $current = $db->loadObject(); } HTML_versions::show($rows, $current); break; } /** * Checks whether a users group is at or above the requested admin group * * @param unknown_type $user_group_id * @param unknown_type $requested_group_id */ function canAccess($user_group_id, $requested_group_id) { if ($requested_group_id == 30) { if ($user_group_id >= 23) { return true; } }