Skip to content

Commit

Permalink
rename function _getProperMediaRevision to _getLastMediaRevisionAt
Browse files Browse the repository at this point in the history
reduce a bit duplicated code
  • Loading branch information
lisps committed Nov 22, 2013
1 parent d811780 commit 52dc5ea
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions inc/parser/xhtml.php
Expand Up @@ -796,23 +796,15 @@ function internalmedia ($src, $title=null, $align=null, $width=null,

list($ext,$mime,$dl) = mimetype($src,false);
if(substr($mime,0,5) == 'image' && $render){
if($this->date_at) {
$link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache,'rev'=>$this->_getProperMediaRevision($src)),($linking=='direct'));
} else {
$link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),($linking=='direct'));
}
$link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache,'rev'=>$this->_getLastMediaRevisionAt($src)),($linking=='direct'));
}elseif($mime == 'application/x-shockwave-flash' && $render){
// don't link flash movies
$noLink = true;
}else{
// add file icons
$class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
$link['class'] .= ' mediafile mf_'.$class;
if($this->date_at) {
$link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache,'rev'=>$this->_getProperMediaRevision($src)),true);
} else {
$link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),true);
}
$link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache,'rev'=>$this->_getLastMediaRevisionAt($src)),true);
if ($exists) $link['title'] .= ' (' . filesize_h(filesize(mediaFN($src))).')';
}

Expand Down Expand Up @@ -1060,7 +1052,6 @@ function _media ($src, $title=null, $align=null, $width=null,
$height=null, $cache=null, $render = true) {

$ret = '';
$intern = !media_isexternal($src);
list($ext,$mime,$dl) = mimetype($src);
if(substr($mime,0,5) == 'image'){
// first get the $title
Expand All @@ -1085,11 +1076,7 @@ function _media ($src, $title=null, $align=null, $width=null,
return $title;
}
//add image tag
if($intern && $this->date_at) {
$ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache,'rev'=>$this->_getProperMediaRevision($src))).'"';
} else {
$ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache)).'"';
}
$ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache,'rev'=>$this->_getLastMediaRevisionAt($src))).'"';
$ret .= ' class="media'.$align.'"';

if ($title) {
Expand Down Expand Up @@ -1239,15 +1226,16 @@ function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $rende
}

/**
* _getProperMediaRevision is a helperfunction to internalmedia() and _media()
* _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media()
* which returns an existing media revision less or equal to rev or date_at
*
* @author lisps
* @param string $media_id
* @access protected
* @return string revision ('' for current)
*/
function _getProperMediaRevision($media_id){
function _getLastMediaRevisionAt($media_id){
if(!$this->date_at || media_isexternal($media_id)) return '';
$pagelog = new MediaChangeLog($media_id);
return $pagelog->getLastRevisionAt($this->date_at);
}
Expand Down

0 comments on commit 52dc5ea

Please sign in to comment.