info = $info;
}
/**
* fileicon of the page or media file
* used in [Ui\recent]
*
* @return string
*/
public function itemIcon()
{
$id = $this->info['id'];
$html = '';
switch ($this->info['item']) {
case 'media': // media file revision
$html = media_printicon($id);
break;
case 'page': // page revision
$html = '
';
}
return $html;
}
/**
* edit date and time of the page or media file
* used in [Ui\recent, Ui\Revisions]
*
* @param bool $checkTimestamp enable timestamp check, alter formatted string when timestamp is false
* @return string
*/
public function editDate($checkTimestamp = false)
{
$formatted = dformat($this->info['date']);
if ($checkTimestamp && $this->info['timestamp'] === false) {
// exact date is unknown for item has externally deleted or older file restored
// when unknown, alter formatted string "YYYY-mm-DD HH:MM" to "____-__-__ __:__"
$formatted = preg_replace('/[0-9a-zA-Z]/','_', $formatted);
}
return ''. $formatted .'';
}
/**
* edit summary
* used in [Ui\recent, Ui\Revisions]
*
* @return string
*/
public function editSummary()
{
return ''.' – '. hsc($this->info['sum']).'';
}
/**
* editor of the page or media file
* used in [Ui\recent, Ui\Revisions]
*
* @return string
*/
public function editor()
{
$html = '';
if ($this->info['user']) {
$html.= ''. editorinfo($this->info['user']) .'';
if (auth_ismanager()) $html.= ' ('. $this->info['ip'] .')';
} else {
$html.= ''. $this->info['ip'] .'';
}
$html.= '';
return $html;
}
/**
* name of the page or media file
* used in [Ui\recent, Ui\Revisions]
*
* @return string
*/
public function itemName()
{
$id = $this->info['id'];
$rev = ($this->info['current']) ? '' : $this->info['date'];
switch ($this->info['item']) {
case 'media': // media file revision
$params = ['tab_details'=> 'view', 'ns'=> getNS($id), 'image'=> $id];
if ($rev) $params += ['rev'=> $rev];
$href = media_managerURL($params, '&');
if(file_exists(mediaFN($id, $rev))) {
$class = 'wikilink1';
} else {
$class = 'wikilink2';
if(!$this->info['current']) {
//revision is not in attic
return $id;
}
}
return ''.$id.'';
case 'page': // page revision
$params = $rev ? ['rev'=> $rev] : [];
$href = wl($id, $params, false, '&');
$display_name = useHeading('navigation') ? hsc(p_get_first_heading($id)) : $id;
if (!$display_name) $display_name = $id;
if(page_exists($id, $rev)) {
$class = 'wikilink1';
} else {
$class = 'wikilink2';
if(!$this->info['current']) {
//revision is not in attic
return $display_name;
}
}
return ''.$display_name.'';
}
return '';
}
/**
* difflink icon in recents list
* all items in the recents are "current" revision of the page or media
*
* @return string
*/
public function difflinkRecent()
{
global $lang;
$id = $this->info['id'];
$href = '';
switch ($this->info['item']) {
case 'media': // media file revision
$revs = (new MediaChangeLog($id))->getRevisions(0, 1);
$showLink = (count($revs) && file_exists(mediaFN($id)));
if ($showLink) {
$href = media_managerURL(
['tab_details'=>'history', 'mediado'=>'diff', 'image'=> $id, 'ns'=> getNS($id)], '&'
);
}
break;
case 'page': // page revision
if($this->info['type'] !== DOKU_CHANGE_TYPE_CREATE) {
$href = wl($id, "do=diff", false, '&');
}
}
if ($href) {
$html = ''
. '
'
. '';
} else {
$html = '
';
}
return $html;
}
/**
* difflink icon in revsions list
* the icon does not displayed for the current revision
*
* @return string
*/
public function difflinkRevision()
{
global $lang;
$id = $this->info['id'];
$rev = $this->info['date'];
switch ($this->info['item']) {
case 'media': // media file revision
if ($this->info['current'] || !file_exists(mediaFN($id, $rev))) {
$html = '
';
} else {
$href = media_managerURL(['image'=> $id, 'rev'=> $rev, 'mediado'=>'diff'], '&');
$html = ''
. '
'
. ' ';
}
return $html;
case 'page': // page revision
if ($this->info['current'] || !page_exists($id, $rev)) {
$html = '
';
} else {
$href = wl($id, "rev=$rev,do=diff", false, '&');
$html = ''
. '
'
. '';
}
return $html;
}
return '';
}
/**
* icon revision link
* used in [Ui\recent]
*
* @return string
*/
public function revisionlink()
{
global $lang;
if (!actionOK('revisions')) {
return ''; //FIXME check page, media
}
$id = $this->info['id'];
$href = '';
switch ($this->info['item']) {
case 'media': // media file revision
$href = media_managerURL(['tab_details'=>'history', 'image'=> $id, 'ns'=> getNS($id)], '&');
break;
case 'page': // page revision
$href = wl($id, "do=revisions", false, '&');
}
return ''
. '
'
. '';
}
/**
* size change
* used in [Ui\recent, Ui\Revisions]
*
* @return string
*/
public function sizeChange()
{
$class = 'sizechange';
$value = filesize_h(abs($this->info['sizechange']));
if ($this->info['sizechange'] > 0) {
$class .= ' positive';
$value = '+' . $value;
} elseif ($this->info['sizechange'] < 0) {
$class .= ' negative';
$value = '-' . $value;
} else {
$value = '±' . $value;
}
return ''.$value.'';
}
/**
* current indicator, used in revison list
* not used in Ui\Recents because recent items are always current one
*
* @return string
*/
public function currentIndicator()
{
global $lang;
return ($this->info['current']) ? '('.$lang['current'].')' : '';
}
}